<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How to output report in CSV? in Microsoft Virtualization Discussions</title>
    <link>https://community.netapp.com/t5/Microsoft-Virtualization-Discussions/How-to-output-report-in-CSV/m-p/111129#M4543</link>
    <description>&lt;P&gt;The cleanest (IMO)&amp;nbsp;way is to create a custom object, and use Export-Csv to write the CSV file.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Something like this should do the trick (haven't executed this, so please excuse any syntax errors).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;$date = Get-Date -Format yyyy-MM-dd

foreach ($filer in Get-Content \\[network share]\FILERS.txt) { 
  $c = Connect-NaController -Name $filer; 
  $aggrs = Get-Naaggr 
  foreach ($aggr in $aggrs)
  {
      $obj = [PSCustomObject]@{
        ReportDate = $date
        Capacity = $aggr.TotalSize #Convert to TB if required
        Free = $aggr.Available
        FilerName = $filer
      }
      $obj | Export-CSV -Path somePath -Append
  }
}&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If Capacity &amp;amp; Free are to be reported per-filer, then&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;$date = Get-Date -Format yyyy-MM-dd

foreach ($filer in Get-Content \\[network share]\FILERS.txt) { 
  $c = Connect-NaController -Name $filer; 
  $sums = Get-Naaggr | Measure-Object -Sum Available,TotalSize
  $obj = [PSCustomObject]@{
        ReportDate = $date
        Capacity = $sums[1].Sum #Convert to TB if required
        Free = $sums[0].Sum
        FilerName = $filer
   }
   $obj | Export-CSV -Path somePath -Append
}&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope this helps,&lt;/P&gt;&lt;P&gt;Aparajita&lt;/P&gt;</description>
    <pubDate>Wed, 14 Oct 2015 14:57:39 GMT</pubDate>
    <dc:creator>Aparajita</dc:creator>
    <dc:date>2015-10-14T14:57:39Z</dc:date>
    <item>
      <title>How to output report in CSV?</title>
      <link>https://community.netapp.com/t5/Microsoft-Virtualization-Discussions/How-to-output-report-in-CSV/m-p/111127#M4542</link>
      <description>&lt;P&gt;I'm running a below powershell script to report on our capacity but recently I was asked to provide it in CSV format. &amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000FF"&gt;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)}}}&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Current report looks like this:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Controller:&amp;nbsp;xxxxxx&lt;/P&gt;&lt;P&gt;Aggr State TotalSize(TB) Available&lt;BR /&gt;---- ----- ------------- ---------&lt;BR /&gt;aggr2 online 40.74 &amp;nbsp; &amp;nbsp; &amp;nbsp; 6.92&lt;BR /&gt;aggr3 online 20.37 &amp;nbsp; &amp;nbsp; &amp;nbsp; 16.72&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How can I modify the script to output in CSV? &amp;nbsp;Can I have it output in the fields as follows?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2" color="#FF0000"&gt;ReportDate &amp;nbsp; &amp;nbsp;Capacity &amp;nbsp; Free &amp;nbsp;FilerName &amp;nbsp;&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;2015-10-14 &amp;nbsp; &amp;nbsp; &amp;nbsp; xxxx &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;xxx &amp;nbsp; &amp;nbsp; &amp;nbsp;xxxxx&lt;/P&gt;</description>
      <pubDate>Wed, 04 Jun 2025 23:03:00 GMT</pubDate>
      <guid>https://community.netapp.com/t5/Microsoft-Virtualization-Discussions/How-to-output-report-in-CSV/m-p/111127#M4542</guid>
      <dc:creator>NAMAN</dc:creator>
      <dc:date>2025-06-04T23:03:00Z</dc:date>
    </item>
    <item>
      <title>Re: How to output report in CSV?</title>
      <link>https://community.netapp.com/t5/Microsoft-Virtualization-Discussions/How-to-output-report-in-CSV/m-p/111129#M4543</link>
      <description>&lt;P&gt;The cleanest (IMO)&amp;nbsp;way is to create a custom object, and use Export-Csv to write the CSV file.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Something like this should do the trick (haven't executed this, so please excuse any syntax errors).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;$date = Get-Date -Format yyyy-MM-dd

foreach ($filer in Get-Content \\[network share]\FILERS.txt) { 
  $c = Connect-NaController -Name $filer; 
  $aggrs = Get-Naaggr 
  foreach ($aggr in $aggrs)
  {
      $obj = [PSCustomObject]@{
        ReportDate = $date
        Capacity = $aggr.TotalSize #Convert to TB if required
        Free = $aggr.Available
        FilerName = $filer
      }
      $obj | Export-CSV -Path somePath -Append
  }
}&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If Capacity &amp;amp; Free are to be reported per-filer, then&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;$date = Get-Date -Format yyyy-MM-dd

foreach ($filer in Get-Content \\[network share]\FILERS.txt) { 
  $c = Connect-NaController -Name $filer; 
  $sums = Get-Naaggr | Measure-Object -Sum Available,TotalSize
  $obj = [PSCustomObject]@{
        ReportDate = $date
        Capacity = $sums[1].Sum #Convert to TB if required
        Free = $sums[0].Sum
        FilerName = $filer
   }
   $obj | Export-CSV -Path somePath -Append
}&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope this helps,&lt;/P&gt;&lt;P&gt;Aparajita&lt;/P&gt;</description>
      <pubDate>Wed, 14 Oct 2015 14:57:39 GMT</pubDate>
      <guid>https://community.netapp.com/t5/Microsoft-Virtualization-Discussions/How-to-output-report-in-CSV/m-p/111129#M4543</guid>
      <dc:creator>Aparajita</dc:creator>
      <dc:date>2015-10-14T14:57:39Z</dc:date>
    </item>
  </channel>
</rss>

