Created
October 29, 2013 12:17
-
-
Save BenNeise/7213597 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment