Community maintenance is complete. Thank you for your patience!

Microsoft Virtualization Discussions

Get-NaAggrSpace

JSHACHER11

Hi guys,

I am trying to export to CSV a list/table of Aggregate space stats. This isn't working:

================================================

$aggr = Get-NaAggrSpace

$customobject = new-object psobject

add-member -inputobject $customobject -membertype noteproperty -name Aggregate -value $aggr.AggregateName

add-member -inputobject $customobject -membertype noteproperty -name Free_Size -value $aggr.SizeFree

add-member -inputobject $customobject -membertype noteproperty -name Snapshots_Use -value $aggr.SizeSnapUsed

add-member -inputobject $customobject -membertype noteproperty -name Used -value $aggr.SizeUsed

add-member -inputobject $customobject -membertype noteproperty -name Volumes_Use -value $aggr.SizeVolumeUsed

add-member -inputobject $customobject -membertype noteproperty -name Volumes -value $aggr.Volumes

$customobject | export-csv c:\aggr_size.csv -notypeinformation

===============================================

what would be the best way? I would also like to export it in different units (MB, GB,..)

Thank you

Joel

16 REPLIES 16

vinith

This should work for you

Get-NaAggrSpace | select AggregateName,@{l='SizeFree(GB)';e={([math]::Round([decimal]($_.SizeFree)/1gb,2))}},@{l='SizeSnapUsed(GB)';e={([math]::Round([decimal]($_.SizeSnapUsed)/1gb,2))}},@{l='SizeUsed(GB)';e={([math]::Round([decimal]($_.SizeUsed)/1gb,2))}},@{l='SizeVolumeUsed(GB)';e={([math]::Round([decimal]($_.SizeVolumeUsed)/1gb,2))}},@{label="Volumes";expression={$_.volumes -join ","}} | Export-Csv "c:\vins.csv"

JSHACHER11

thanks - I will try that now

what does the  '-join' do?

vinith

The join operator concatenates a set of strings into a single string., for mode details check out

PS C:\Users\vinith> Get-Help about_join

JSHACHER11

the output isn't working. I am getting rows instead of columns in the CSV file

JSHACHER11

this is what I am getting - I need a list of volumes in a column, not a row - is that possible? I guess we need to create a file for each aggregate?

AggregateNameSizeFree(GB)SizeSnapUsed(GB)SizeUsed(GB)SizeVolumeUsed(GB)Volumes

aggr0                             2GB                                   1GB                        1GB                  1GB                       vol0, vol1, vol2, vol3, vol4,....

JGPSHNTAP

Joel -

Your first example isn't going to work because you don't loop through the array.    Also, you don't really need to create custom objects in this example b/c they are already created

Why do you need a list of volumes in a row?  

JGPSHNTAP

Joel - do a search for an excel report I wrote that will give you a dashboard, Try that out and see if thats what you need

JGPSHNTAP

yeah

JSHACHER11

that was last year and in there you stated that "I'm in no way a powershell expert" - I can tell you that it's not true anymore

thanks for the help

JGPSHNTAP

Joel -

Slow down a little ...

It's not working because it's an array of objects.  That's why.  I know your just getting started with PS, you need to read up on it a little.  Can't all be trial by fire

JSHACHER11

"Why do you need a list of volumes in a row?"

easy to read

I can have the list of volumes in a separated list though

JSHACHER11

why is this not working:

$aggr = Get-NaAggrSpace

$aggr.SizeFree

vinith

this is how the output should look like.

JSHACHER11

is there an easy way to change the size from GB units to MB globally?

vinith

you can just replace 'gb' with 'mb' in above code to get your output in mb. check this technet link http://technet.microsoft.com/en-us/library/ee692684.aspx

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