Microsoft Virtualization Discussions

Simple powershell script to get a snashot total size per volume


I wonder if anyone could post a script that does simple thing - list of volumes per FAS with Snapshot Total size and may be a number of Shapshots per each volume.

Thanks for the help!



Hi Andrey,


If you are looking for an output like


Controller          Vserver::Volume               SpaceOccupiedBySnapshot                      TotalSnapshots
----------          ---------------               -----------------------                      --------------        aparajir-vvsim-01::vol0       1.8 GB                                                   16                  aparajir-vvsim-02::vol0       1.8 GB                                                   16                  cifs_vs::cifs_vs0             716.0 KB                                                 10 vs_inf::vs1_ns 1.6 MB 10 vs_inf::vs1_ns_mirror0001 1.6 MB 11

script below ought to do the trick



$controllers = @{ 
"" = $credential1
"" = $credential2

foreach ($controller in $controllers.Keys) {

$conn = Connect-NcController $controller -Credential $controllers[$controller]

$vols = Get-NcVol
foreach ($vol in $vols) {
$measure = Get-NcSnapshot $vol.Name | Measure-Object Total -Sum
$op = New-Object psobject
Add-Member -InputObject $op -Name Controller -MemberType NoteProperty -Value $global:CurrentNcController.Name
$volName = $vol.Vserver + "::" + $vol.Name
Add-Member -InputObject $op -Name "Vserver::Volume" -MemberType NoteProperty -Value $volName
$totalSpace = ConvertTo-FormattedNumber $measure.Sum DataSize "0.0"
Add-Member -InputObject $op -Name SpaceOccupiedBySnapshot -MemberType NoteProperty -Value $totalSpace
Add-Member -InputObject $op -Name TotalSnapshots -MemberType NoteProperty -Value $measure.Count
Write-Output $op



This script is for Clustered DataONTAP. If you are running a 7-mode controller, it shouldn't be too difficult to adapt this. Also, if you are interested in a report, you may want to output as CSV, rather than creating an output object.


Hope this helps,


NetApp on Discord Image

We're on Discord, are you?

Live Chat, Watch Parties, and More!

Explore Banner

Meet Explore, NetApp’s digital sales platform

Engage digitally throughout the sales process, from product discovery to configuration, and handle all your post-purchase needs.

NetApp Insights to Action
I2A Banner