If you’re using templates in ESX, and guest customisation fails when the drive is set to non-persistent.

This script looks at your templates, and outputs a list of those with non-persistent drives.

# Set up an empty array
$arrTemplatesWithPersistentDrives = @()
 
# Get all the template objects
$objTemplates = Get-Template
 
# Loop through each template
ForEach ($objTemplate in $objTemplates){
    # Get the drives associated with that template
    $objHardDisks = $objTemplate | Get-HardDisk
    # Loop through each drive
    ForEach    ($objHardDisk in $objHardDisks){
        # If any of the drives are non-persistent, add the template object to the empty array
        If ($objHardDisk.Persistence -match "non"){$arrTemplatesWithPersistentDrives += $objTemplate}
        }
    }
 
# List the names of the unique templates in the array (as a template with more than one non-perisistent drive would appear more than once)
$arrTemplatesWithPersistentDrives | Sort-Object -Unique | Select-Object Name

Comments

  1. Webmaster Crap » Blog Archive » Find Templates with Non-Persistent Drives « ben.neise.co.uk on 03.24.2009

    [...] Read the rest here:  Find Templates with Non-Persistent Drives « ben.neise.co.uk [...]

Leave a Reply