johnlennon
Enthusiast
Enthusiast

List the active snapshot of VMs

Jump to solution

In our staging environment we're going to test automation to upgrade to the new builds. I regularly need to make sure the VMs are running with a snapshot taken at the same time (via PowerCLI, we use the same description).

In other words, is there a way to retrieve the current active snapshot name for all VMs?

Using:

get-resourcepool "MyResPool" | get-vm | get-snapshot | select @{Name="VM Name";  Expression={$_.VM.Name}}, created, name, description | Sort-Object  created | Format-Table -auto

doesn't highlight which one is active.

0 Kudos
1 Solution

Accepted Solutions
RvdNieuwendijk
Leadership
Leadership

The IsCurrent property of a snapshot tells you if a snapshot is current. I modified your script to only show the active snapshots:

Get-ResourcePool "MyResPool" | `
Get-VM | `
Get-Snapshot | `
Where-Object {$_.IsCurrent} | `
Select @{Name="VM Name";Expression={$_.VM.Name}},Created,Name,Description | `
Sort-Object -Property Created | `
Format-Table -AutoSize

Regards, Robert

Blog: https://rvdnieuwendijk.com/ | Twitter: @rvdnieuwendijk | Author of: https://www.packtpub.com/virtualization-and-cloud/learning-powercli-second-edition

View solution in original post

0 Kudos
3 Replies
pcerda
Virtuoso
Virtuoso

Check out this link:

http://blog.axiomdynamics.com/2010/03/powercli-script-for-snapshot-reporting.html

Best Regards

Regards / Saludos - Patricio Cerda - vExpert 2011 / 2012 / 2013
0 Kudos
RvdNieuwendijk
Leadership
Leadership

The IsCurrent property of a snapshot tells you if a snapshot is current. I modified your script to only show the active snapshots:

Get-ResourcePool "MyResPool" | `
Get-VM | `
Get-Snapshot | `
Where-Object {$_.IsCurrent} | `
Select @{Name="VM Name";Expression={$_.VM.Name}},Created,Name,Description | `
Sort-Object -Property Created | `
Format-Table -AutoSize

Regards, Robert

Blog: https://rvdnieuwendijk.com/ | Twitter: @rvdnieuwendijk | Author of: https://www.packtpub.com/virtualization-and-cloud/learning-powercli-second-edition
0 Kudos
johnlennon
Enthusiast
Enthusiast

Thank you Robert, this is exactly what I was looking for.

0 Kudos