ONTAP Discussions
ONTAP Discussions
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.
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
apappcl5Qquorum | 2 | 0.99 | 0.50 | |
apappcl5Qquorum_T | 2 | 0.99 | 0.50 | |
apAVLcl2Ga | 100 | 49.79 | 0.50 | |
apAVLcl2Qquorum | 2 | 0.99 | 0.50 | |
apcl5Ga | 20 | 9.95 | 0.50 | |
apcl5Ga_T | 30 | 19.95 | 0.33 | |
apcl5Xdtc | 2 | 0.99 | 0.50 | |
apfinpapp | 8 | 1.87 | 0.77 | |
apidashcl6 | 70 | 69.53 | 0.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.
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?