Some friends here on the Hyper-V team shared a PowerShell 2.0 script for getting a list of snapshots:
# List Virtual System Snapshots #Obtain the VM name $VM_Name= Read-Host("Please specify the name of the VM ") $HostName = "." #obtain the Msvm_ComputerSystem reference $SourceSystem = get-wmiobject -namespace root\virtualization -class Msvm_ComputerSystem -filter " ElementName = '$VM_Name' " #List the existing VM snapshots Write-Host `n " $VM_Name Snapshots :" $i=1 get-wmiobject -namespace root\virtualization -class Msvm_VirtualSystemSettingData -filter "SystemName=`'$($SourceSystem.Name)`' and SettingType = 5”| ForEach-Object{ Write-Host "($i)" $_.ElementName $i++ }
# List Virtual System Snapshots
#Obtain the VM name $VM_Name= Read-Host("Please specify the name of the VM ") $HostName = "."
#obtain the Msvm_ComputerSystem reference $SourceSystem = get-wmiobject -namespace root\virtualization -class Msvm_ComputerSystem -filter " ElementName = '$VM_Name' "
#List the existing VM snapshots Write-Host `n " $VM_Name Snapshots :" $i=1 get-wmiobject -namespace root\virtualization -class Msvm_VirtualSystemSettingData -filter "SystemName=`'$($SourceSystem.Name)`' and SettingType = 5”| ForEach-Object{ Write-Host "($i)" $_.ElementName $i++ }
For more info on how to use PS cmdlets see: http://www.microsoft.com/technet/scriptcenter/topics/msh/cmdlets/index.mspx
See also James O’Neil’s New and improved PowerShell Library for Hyper-V. Now with more functions and... documentation!
For all 35 sample Hyper-V PS1 scripts in a zipfile, go to: Hyper-V PowerShell Example Scripts.zip-download