Following on from a post I created a while back which gave you a couple of new functions to use with Auto Deploy I wanted to add a few extra pieces of code which I use on a regular basis that may save people time when they are building out their image profiles or working with auto deploy:
Adding the VMware hosted software depots to your PowerCLI Session:
Add-EsxSoftwareDepot https://hostupdate.vmware.com/software/VUM/PRODUCTION/main/vmw-depot-index.xml
Listing the 5 most recent image profiles from the online depot (Thanks to Andreas Peetz):
Get-EsxImageProfile | Sort-Object -Descending -Property @{Expression={$_.Name.Substring(0,10)}},@{Expression={$_.CreationTime.Date}},Name | Select -first 5 | FT -AutoSize
List the latest image profile which includes VMTools:
Get-EsxImageProfile | Sort-Object -Descending -Property @{Expression={$_.Name.Substring(0,10)}},@{Expression={$_.CreationTime.Date}},Name | Where { $_.Name -notmatch "no-tools"} | Select -first 1 | Format-Table –AutoSize
List the latest image profile which does not include VMTools:
Get-EsxImageProfile | Sort-Object -Descending -Property @{Expression={$_.Name.Substring(0,10)}},@{Expression={$_.CreationTime.Date}},Name | Where { $_.Name -match "no-tools"} | Select -first 1 | Format-Table –AutoSize
Export the latest Image profile with VMTools to disk so that we can use it later:
$IP = Get-EsxImageProfile | Sort-Object -Descending -Property @{Expression={$_.Name.Substring(0,10)}},@{Expression={$_.CreationTime.Date}},Name | Where { $_.Name -notmatch "no-tools"} | Select -first 1 Export-EsxImageProfile -ImageProfile $IP -FilePath C:\Tmp\LatestImage.zip –ExportToBundle
When everything looks right in your rule set and your Image Profiles are still not booting correctly make sure you have checked the rule set compliance and repaired it with the following:
Test the rule set compliance for all hosts:
Get-VMHost | Test-DeployRuleSetCompliance
Repair the rule set compliance for all hosts:
Get-VMHost | Test-DeployRuleSetCompliance | Repair-DeployRuleSetCompliance
Pingback: Обзор блогов от 25.06.13 | vMind.ru
Absolutely correct, teaches me not to double check! thanks for the code, i have updated the post and given you credit 🙂
Hi Alan,
“Get-EsxImageProfile | Sort-Object -Property Creationtime -Descending | Select -First 5” does NOT really list the five most recent image profiles (just look at the result in your screenshot!), because the CreationTime property is not accurate for most profiles (rit’s not really the date they were published).
As a reliable workaround I use the following code in my ESXi-Customizer-PS script to sort the list:
Sort-Object -Descending -Property @{Expression={$_.Name.Substring(0,10)}},@{Expression={$_.CreationTime.Date}},Name
– Andreas