I am seeking a PowerCLI command to list SnapShots size with a Datastore on the storage level. I could not find the information in GUI.
Thank You!
Discussion moved from VMware vSphere™ to VMware PowerCLI
You could do something like this
$ds = Get-Datastore -Name $dsName
$snaps = $ds | Get-VM | Get-Snapshot
$ds | Select Name,@{N='SnapshotSizeGB';E={
[math]::Round(($snaps | Measure-Object -Property SizeGB -sum).Sum,1)}}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
LucD,
I am looking for Snapshots for Datastore on NFS storage level, not for VM's.
Thanks for replying.
Not sure I get what you mean.
Can you show a screenshot? Or some more details?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Ok, got it.
Try something like this
$ds = Get-Datastore -Name $datastoreName
New-PSDrive -Location $ds -Name DS -PSProvider VimDatastore -Root '\' | Out-Null
$size = Get-ChildItem -Path "DS:\.snapshot" -Recurse | Measure-Object -Property Length -Sum | select -ExpandProperty Sum
Remove-PSDrive -Name DS -Confirm:$false
Write-Host "Folder .snapshot holds $([math]::Round($size/1GB,1)) GB"
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Your script is hanging on the line with Recursive...
Any idea why?
Thanks!
The datastore provider is not extremely fast.
I suspect it just might be running for a very long time.
You could test with a datastore that has less content.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
After extremely long time, it finally broken. The Snapshots size is not that large, only 10 ones.
Do you mean 'completed' or 'ended with an error' with 'broke'?
It's not as much the size of the files in that folder, more the number of files and how deep the folders are nested, that determines how long it will run.
An alternative, and faster method, would be to connect via SSH to the ESXi nodes, and do a 'du' from there.
But it require to enable SSH and have access to an account that can logon on the ESXi node.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference