Who Me Too'd this topic

About Microsoft Virtualization Discussions
Discuss NetApp solutions for Microsoft Private Cloud and the Hyper-V platform, including FlexPod Datacenter, NetApp OnCommand Plug-in for Microsoft, and Data ONTAP PowerShell Toolkit.

Is there a better way query volume total space in powershell?

My boss wanted information about the total capacity of each of our volumes(So including snapshot reserve) along with used space and available. I was going to use get-navol but i noticed this only gives the usable space of the volume not the true total. So i hacked together this script using both get-navol and get-navolsize cmd-let to get what i needed. This is my second script i have ever wrote in PowerShell so i am sure i did a several things wrong but i was able to get the results i wanted. It just seems like it should have been less work and a better way of doing this.

VolumeName,VolumeAvailableSpace,VolumeUsedSpace,VolumeTotalsize

param([string]$paNetAppHost, [string]$pausername)

Import-module DataOnTap

$PathtoCSV = "C:\NetappTotalVolume.csv"

#Connect to filer

Connect-NAController $paNetAppHost–cred $pausername

$allvolumesnames = get-navol | Select-Object Name,Available

#set headers of CSV file

"VolumeName,Available Space(GB),Used Space(GB),Total Volume Space(GB)" > $PathtoCSV

foreach ($netapp_vol in $allvolumesnames) {

$CurrentVolname = $netapp_vol.name

$VolumesAvailable = $netapp_vol.available

$VolumeSizeTotal = get-navolsize -name $CurrentVolname | Select-Object -ExpandProperty VolumeSize

#Convert to GB

$VolumeAvailable1GB = ($VolumesAvailable / 1GB)

$VolumeSizeTotal1GB = ($VolumeSizeTotal / 1GB)

#Calc usedspace

$VolumeUsedSpace1GB = $VolumeSizeTotal1GB - $VolumeAvailable1GB

#Create/add to CSV file

$Combine = $CurrentVolname,$VolumeAvailable1GB,$VolumeUsedSpace1GB,$VolumeSizeTotal1GB

$Combine -join "," >> $PathtoCSV

    }

Who Me Too'd this topic