- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
thanks - I will try that now
what does the '-join' do?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
is there an easy way to change the size from GB units to MB globally?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
the output isn't working. I am getting rows instead of columns in the CSV file
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
this is how the output should look like.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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?
| AggregateName | SizeFree(GB) | SizeSnapUsed(GB) | SizeUsed(GB) | SizeVolumeUsed(GB) | Volumes |
aggr0 2GB 1GB 1GB 1GB vol0, vol1, vol2, vol3, vol4,....
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
"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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
why is this not working:
$aggr = Get-NaAggrSpace
$aggr.SizeFree
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yeah
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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