NetApp Community Update
This site will enter Read Only mode on July 23 as we prepare to move to a new platform.
You will still be able to view content, but posting and replying will be temporarily disabled.
To learn more, please review the information in this blog post.

ONTAP Discussions

CIFS NDO and Continuously Available Shares

zenmatrix83
2,765 Views

This is my first attempt at using the powershell toolkit, I'm trying to get a list of the space available on all of our cifs and nfs shares. It mostly works but its a bit clunky and I was wondering if anyone has any suggestiosn

 

$report=@();

$cifShares=Get-NcCifsShare | select ShareName,Volume
foreach($cifShare in $cifShares)
{
$object=New-Object System.object
$object | Add-Member -Type NoteProperty -Name "Share Name" -Value $cifShare.ShareName
$object | Add-Member -Type NoteProperty -Name "Volume Name" -Value $cifShare.Volume
$vol=Get-Ncvol $cifShare.Volume | Select TotalSize,Available,Used
$volTotalSize=$vol.TotalSize | ConvertTo-FormattedNumber -Type DataSize
$volAvailableSize=$vol.Available | ConvertTo-FormattedNumber -Type DataSize
$object | Add-Member -Type NoteProperty -Name "Total Size" -Value $volTotalSize
$object | Add-Member -Type NoteProperty -Name "Available" -Value $volAvailableSize
$object | Add-Member -Type NoteProperty -Name "Used" -Value $vol.Used
$report+=$object
$object
}

$nfsExports=Get-NcNfsExport | where {$_.JunctionPath -ne "/"}
foreach ($nfsExport in $nfsExports)
{
$vol=Get-NcVol | where {$_.JunctionPath -eq $nfsExport.Pathname -and $_.JunctionPath -ne "/"}
if($vol.JunctionPath -eq $nfsExport.Pathname)
{
$volTotalSize=$vol.TotalSize | ConvertTo-FormattedNumber -Type DataSize
$volAvailableSize=$vol.Available | ConvertTo-FormattedNumber -Type DataSize
$object=New-Object System.object
$object | Add-Member -Type NoteProperty -Name "Share Name" -Value $nfsExport.Pathname
$object | Add-Member -Type NoteProperty -Name "Volume Name" -Value $vol.Name
$object | Add-Member -Type NoteProperty -Name "Total Size" -Value $volTotalSize
$object | Add-Member -Type NoteProperty -Name "Available" -Value $volAvailableSize
$object | Add-Member -Type NoteProperty -Name "Used" -Value $vol.Used
$report+=$object
$object
}

 

}
$report | export-csv -NoTypeInformation C:\netappcifsnfs.csv

1 REPLY 1

darraghos
2,701 Views

Since you're exporting, I don't think its clunky. If you want a one liner use calcualted properties of select-object.

Public