ONTAP Discussions

get volume details from a specific list of volumes.

Pufferth
5,249 Views

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.

 

apAVLcl2Ga
apAVLcl2Qquorum
apcl5Ga
apcl5Ga_T
apcl5Xdtc
apfinpapp
apidashcl6
apidashcl6_Q
apLIMcl2Ga
apLIMclQquorum
apTYMcl6Ga
apTYMcl6Qquorum


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.

6 REPLIES 6

JGPSHNTAP
5,234 Views

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

bazmercer
5,194 Views

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

}

Pufferth
5,170 Views

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

 apappcl5Qquorum20.990.50
 apappcl5Qquorum_T20.990.50
 apAVLcl2Ga10049.790.50
 apAVLcl2Qquorum20.990.50
 apcl5Ga209.950.50
 apcl5Ga_T3019.950.33
 apcl5Xdtc20.990.50
 apfinpapp81.870.77
 apidashcl67069.530.01

 

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.

JGPSHNTAP
5,165 Views

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?

Pufferth
5,156 Views

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
}

 

 

JGPSHNTAP
5,146 Views

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?

Public