PowerCLI

 View Only
  • 1.  Powercli Commands to list SnapShot size on a Datastore?

    Posted May 14, 2018 06:52 PM

    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!



  • 2.  RE: Powercli Commands to list SnapShot size on a Datastore?

    Posted May 14, 2018 07:01 PM

    Discussion moved from VMware vSphere™ to VMware PowerCLI



  • 3.  RE: Powercli Commands to list SnapShot size on a Datastore?

    Posted May 14, 2018 07:13 PM

    You could do something like this

    $dsName = 'datastore1'

    $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)}}



  • 4.  RE: Powercli Commands to list SnapShot size on a Datastore?

    Posted May 14, 2018 07:19 PM

    LucD,

    I am looking for Snapshots for Datastore on NFS storage level, not for VM's. 

    Thanks for replying.



  • 5.  RE: Powercli Commands to list SnapShot size on a Datastore?

    Posted May 14, 2018 07:46 PM

    Not sure I get what you mean.
    Can you show a screenshot? Or some more details?



  • 6.  RE: Powercli Commands to list SnapShot size on a Datastore?

    Posted May 14, 2018 08:07 PM

    .snapshot

    this is the folder in vSphere.

    Commands you showed me is for snapshots accumulated by VM's.

    The snapshots I am talking about is taken by the storage, not by VM's or vShpere.



  • 7.  RE: Powercli Commands to list SnapShot size on a Datastore?

    Posted May 14, 2018 08:38 PM

    Ok, got it.

    Try something like this

    $datastoreName = 'MyDS'

    $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"



  • 8.  RE: Powercli Commands to list SnapShot size on a Datastore?

    Posted May 14, 2018 09:13 PM

    Your script is hanging on the line with Recursive...

    Any idea why?

    Thanks!



  • 9.  RE: Powercli Commands to list SnapShot size on a Datastore?

    Posted May 15, 2018 04:27 AM

    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.



  • 10.  RE: Powercli Commands to list SnapShot size on a Datastore?

    Posted May 15, 2018 12:24 PM

    After extremely long time, it finally broken.  The Snapshots size is not that large, only 10 ones.



  • 11.  RE: Powercli Commands to list SnapShot size on a Datastore?

    Posted May 15, 2018 12:40 PM

    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.