Microsoft Virtualization Discussions

Simple powershell script to get a snashot total size per volume

Andrey_y
5,382 Views

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!

1 REPLY 1

Aparajita
5,347 Views

Hi Andrey,

 

If you are looking for an output like

 

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

script below ought to do the trick

 

 

$controllers = @{ 
"10.238.48.40" = $credential1
"10.225.183.84" = $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,

Aparajita

Public