VMware Cloud Community
ganapa2000
Hot Shot
Hot Shot
Jump to solution

Get Snapshot VM Memory Info

Hi,

How can I get the VM Snapshot Memory Info using PowerCLI ?

Get-Snapshot MyVM1 | Select-Object -Property Name, @{N="SizeGB";Expression={"{0:N2} GB" -f ($_.SizeGB)}}, VM, Quiesced, PowerState, Children | Sort-Object -Property SizeGB -Descending | ft -AutoSize

0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

That is because that property is a String, you can convert to Int or Float

Get-Snapshot MyVM1 |
Select-Object -Property Name, @{N="SizeGB";Expression={"{0:N2} GB" -f ($_.SizeGB)}},
  @{N='VM';E={$_.Vm.Name}},
  Quiesced, PowerState,
  @{N='Memory';E={
    $snap = $_
    $snapInfo = $_.VM.ExtensionData.LayoutEx.Snapshot | where{$_.Key -eq $snap.Id}
    $snapInfo.MemoryKey -ne -1
  }},
  Children |
Sort-Object -Property {[float]$_.SizeGB} -Descending |
Format-Table -AutoSize


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

View solution in original post

0 Kudos
5 Replies
LucD
Leadership
Leadership
Jump to solution

What exactly do you want to see?
If the memory was included in the snapshot?


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
LucD
Leadership
Leadership
Jump to solution

If you just want to see if the memory was in cluded, True ort False, you could do

Get-Snapshot MyVM1 |
Select-Object -Property Name, @{N="SizeGB";Expression={"{0:N2} GB" -f ($_.SizeGB)}},
  @{N='VM';E={$_.Vm.Name}},
  Quiesced, PowerState,
  @{N='Memory';E={
    $snap = $_
    $snapInfo = $_.VM.ExtensionData.LayoutEx.Snapshot | where{$_.Key -eq $snap.Id}
    $snapInfo.MemoryKey -ne -1
  }},
  Children |
Sort-Object -Property SizeGB -Descending |
Format-Table -AutoSize


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
ganapa2000
Hot Shot
Hot Shot
Jump to solution

LucD,

That worked but sort is not working for SizeGB as I am getting as below.

ganapa2000_0-1664169830813.png

 

0 Kudos
LucD
Leadership
Leadership
Jump to solution

That is because that property is a String, you can convert to Int or Float

Get-Snapshot MyVM1 |
Select-Object -Property Name, @{N="SizeGB";Expression={"{0:N2} GB" -f ($_.SizeGB)}},
  @{N='VM';E={$_.Vm.Name}},
  Quiesced, PowerState,
  @{N='Memory';E={
    $snap = $_
    $snapInfo = $_.VM.ExtensionData.LayoutEx.Snapshot | where{$_.Key -eq $snap.Id}
    $snapInfo.MemoryKey -ne -1
  }},
  Children |
Sort-Object -Property {[float]$_.SizeGB} -Descending |
Format-Table -AutoSize


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
ganapa2000
Hot Shot
Hot Shot
Jump to solution

Thank you very much. that worked now 🙂

0 Kudos