3 Replies Latest reply: Jan 24, 2013 12:46 PM by TONY.UNGER RSS

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

TONY.UNGER
Currently Being Moderated

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

    }

More Like This

  • Retrieving data ...