ONTAP Discussions

get volume details from a specific list of volumes.


I want to get the volume details from a specific list of voulumes.  Below is a section of the code that I am trying to get to work.


Get-Content Vol_BU_Owners_MTRAN.txt
Get-NaVol -name $_  | select name


This is the result.



Name : apappcl5Qquorum

Name : apappcl5Qquorum_T

Name : apAVLcl2Ga

Name : apAVLcl2Qquorum ...



It is getting the volumes from the my list, then it is going back and gets the information from all of the Volumes on the filer.


I have tried several differant script itterations to try and resolve this isssue.  


Here is another example.


Get-Content Vol_BU_Owners_MTRAN.txt | ForEach-Object {Get-NaVol $_  }


Any help will be appreciated.



I don't see a connect to a controller, are we assuming this is done?


And what is your end state goal?  Give me an example.


Also, there is a powershell forum under oncommand somewhere on the forum site


I'm not 100% what you want to happen, you've got a list of volume names and you want to write a script to get all the volume names? Anyway, I think this is what you're after. Maybe...


connect-nacontroller toaster01

$vollist = Get-Content Vol_BU_Owners_MTRAN.txt

foreach ($vol in $vollist){

(get-navol $vol).name



The connection to the controller was just left off, I am connecting to the controllers without issue.


My new report will look something like this.


MTFS1.mc.local VolumeName TotalSize(GB) AvailableSize(GB) % of Space Used



The end result is to analyze usage by Business units, so this will be exported to Excel. 


My mistake with the location of my question first time using this site.


So, if you search the archives in poweshell on this forum, I should have some of my scripts in there which you could use.


But if you want selected columns as you do below, you are going to have to use convertto-formattednumber cmdlet with an expression statement b/c the default cmdlets use a default output.


For example if you do


get-navol vol1 | Select totalsize 


that will look much different then if you do


get-navol vol1


Also, are there other volumes on the controller that you do NOT want  or are those all the volumes?


Below is the full script that I am trying to get to work. I am trying to get a portion of the volumes on this filer, from the list Vol_BU_Owners_MTRAN.txt and thenexport the information to Excel.


$today=get-Date -UFormat %m%d%y
$Volume=Get-Content c:\NetAPP\powershell\Vol_BU_Owners_MTRAN.txt
Connect-NaController xxxx.xxx.xxx
ForEach ($vol in $Volume)
Get-NaVol $vol | Select name @{Label="VolumeName";Expression={$_.name}},@{Name="TotalSize(GB)";Expression={[math]::Round([decimal]$_.totalSize/1gb,2)}},@{Name="AvailableSize(GB)";Expression={[math]::Round([decimal]$_.SizeAvailable/1gb,2)}},@{l='% of Space Used';e={([Math]::Round([decimal]($_.SizeUsed)/($_.SizeTotal),2))}} | Export-Csv c:\NetAPP\VOL_BU_Owners_MTRAN-$today.csv




Ok, that looks ok.


I would use the convertto-formattednumber cmdlet from the data ontap module.  It's easier.



The last line should look like this


| Export-Csv c:\NetAPP\VOL_BU_Owners_MTRAN-$today.csv -append -notypeinformation



Also, I'm not sure what you are doing here


Select name @{Label="VolumeName";Expression={$_.name}}


You already have Name, why create an expression statement for volumename?

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.

NetApp Insights to Action
I2A Banner