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
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
What exactly do you want to see?
If the memory was included in the snapshot?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
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
LucD,
That worked but sort is not working for SizeGB as I am getting as below.
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
Thank you very much. that worked now 🙂