I'm running a below powershell script to report on our capacity but recently I was asked to provide it in CSV format.
foreach ($filer in Get-Content \\[network share]\FILERS.txt) { $c = Connect-NaController -Name $filer; Write-Host "Controller: $filer"; Get-Naaggr | Format-Table -autosize -Property @{label="Aggr";Expression={$_.Name}}, State, @{label="TotalSize(TB)";expression={[math]::round($_.TotalSize / 1tb, 2)}}, @{label="Available";expression={[math]::round($_.Available / 1tb, 2)}}}, @{label="Used";expression={[math]::round($_.Available / 1tb, 2)}}}
Current report looks like this:
Controller: xxxxxx
Aggr State TotalSize(TB) Available
---- ----- ------------- ---------
aggr2 online 40.74 6.92
aggr3 online 20.37 16.72
How can I modify the script to output in CSV? Can I have it output in the fields as follows?
ReportDate Capacity Free FilerName
2015-10-14 xxxx xxx xxxxx