ONTAP Discussions

CIFS NDO and Continuously Available Shares

zenmatrix83

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

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

Announcements
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.

Public