The transition to NetApp MS Azure AD B2C is complete. If you missed the pre-registration, you will be invited to reigister at next log in.
Please note that access to your NetApp data may take up to 1 hour.
To learn more, read the FAQ and watch the video.
Need assistance? Complete this form and select “Registration Issue” as the Feedback Category.

Microsoft Virtualization Discussions

how can i add the volsize function into this

lebedevanton

hi everyone, I found a lot of great stuff on this site, and I am just starting with PS cmdlets and scripts, so I give this board a lot of credit for putting out cmdlets and help with code.

Here is the code that I have, and I want to include the Get-naVolSize into it.

Connect-NaController mysan
$AllAggr=Get-NaAggr
$AllVols=Get-NaVol
$AllLuns=Get-NaLun

foreach ($aggr in $AllAggr | sort Name){
write-Host $aggr.Name ($aggr.sizetotal / 1tb) 'TB'
Foreach ($volume in $AllVols | sort name){
  If ($volume.ContainingAggregate -eq $aggr.Name){
   Write-Host $volume.name' ' ($volume.sizetotal / 1gb)
    }
   }
  }

this part is great and it shows me what I need to see with the aggregate size and volumes in that aggr and their size like so;

aggrSQL     3.7342484 TB

volume_sql1 200 Gb

volume_sql2 100 Gb

How can I also include the get-navolsize cmdlet into this...

what I want to be able to do is generate a similar output, but also show this;

volume_sql1 200 Gb free space left 138 Gb

volume_sql2 100 Gb free space left 20 Gb

I thought about delcaring $VolSize=Get-NaVolSize but I am not sure where to put that, I think I have to pass all the volumes from Get-NaVol to the Get-NaVolSize, but not sure where ?

Thank you.

2 REPLIES 2

lebedevanton

I found http://communities.netapp.com/docs/DOC-6349

and this is exactly what I need to use

cknight

Glad you found what you need.  Here's a quick note on numerical formatting: Toolkit 1.2 adds a cmdlet, ConvertTo-FormattedNumber, for displaying data sizes and other numerical value types in a formatted, readable, and (somewhat) customizable way.  I wrote that one primarily to support the data formatters, but it is documented with examples and you can use it in your own scripts as well.

PS C:\> $aggr0 = Get-NaAggr aggr0
PS C:\> ConvertTo-FormattedNumber $aggr0.SizeTotal DataSize "0.00"
1.10 TB

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.

NetApp Insights to Action
I2A Banner
Public