Microsoft Virtualization Discussions

how can i add the volsize function into this

lebedevanton
2,548 Views

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
2,548 Views

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

and this is exactly what I need to use

cknight
2,548 Views

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

Public