Is there a simple way to get a listing of all of the snapshots on all VMs and how old they are?
Thanks!
Sure, try like this
$now = Get-Date
Get-VM | Get-Snapshot | Select VM,Name,
@{N="Age";E={New-TimeSpan -Start $_.Created -End $now | Select -Expandproperty Days}}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Try it like this
$now = Get-Date
Get-VM | Get-Snapshot | Select VM,Name, @{N="Age";E={New-TimeSpan -Start $_.Created -End $now}}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
OK great thanks. It is showing the age in the format:
9.19:10:46.8243403
where the snapshot in this case is 9 days old.
Can that be adjusted to just show 9 ?
Sure, try like this
$now = Get-Date
Get-VM | Get-Snapshot | Select VM,Name,
@{N="Age";E={New-TimeSpan -Start $_.Created -End $now | Select -Expandproperty Days}}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
works great thanks again