Posts Tagged ‘snapshot’

Snapshot information from PowerCLI

September 6th, 2010 1 comment

Here are some PowerCLI single line scripts for getting different snapshot information:

Display VM Name and Snapshot Name

Get-VM | Get-Snapshot | select @{name="VM Name"; Expression={$}},name

Display VM Name, PowerState, Host and Snapshot Name

Get-VM | Get-Snapshot | select @{name="VM Name"; Expression={$}},@{name="Power State"; Expression={$_.vm.Powerstate}},@{name="Host"; Expression={$_.vm.Host}},name

Display VM Name and Number of Snapshots

Get-VM | Where{(Get-SnapShot -VM $_ | Measure-Object).Count -gt 0} | Format-Table Name, @{Label="NumSnapshots";Expression={(Get-Snapshot -VM $_ | Measure-Object).Count}}

All snapshots older than a particular date, say 30 days?

Get-VM | Get-Snapshot | Where { $_.Created -lt (Get-Date).AddDays(-0)} | select @{name="VM Name"; Expression={$}},@{name="Power State"; Expression={$_.vm.Powerstate}},name, Created