Microsoft Virtualization Discussions


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



Re: Get-NaAggrSpace

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"

Re: Get-NaAggrSpace

thanks - I will try that now

what does the  '-join' do?

Re: Get-NaAggrSpace

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

Re: Get-NaAggrSpace

you can just replace 'gb' with 'mb' in above code to get your output in mb. check this technet link

Re: Get-NaAggrSpace

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

Re: Get-NaAggrSpace

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

Re: Get-NaAggrSpace

this is how the output should look like.

Re: Get-NaAggrSpace

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?


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

Re: Get-NaAggrSpace

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?  

Re: Get-NaAggrSpace

"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

Re: Get-NaAggrSpace

why is this not working:

$aggr = Get-NaAggrSpace


Re: Get-NaAggrSpace

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

Re: Get-NaAggrSpace

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

Re: Get-NaAggrSpace


Cloud Volumes ONTAP
Review Banner
All Community Forums