<?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 Get-NaAggrSpace from multiple filers are failing in Microsoft Virtualization Discussions</title>
    <link>https://community.netapp.com/t5/Microsoft-Virtualization-Discussions/Get-NaAggrSpace-from-multiple-filers-are-failing/m-p/109416#M4485</link>
    <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;foreach ($filer in Get-Content H:\7mode.txt)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;{ $c = Connect-NaController | Get-NaAggrSpace | select AggregateName,@{l='SizeFree(GB)';e={([math]::Round([decimal]($_.SizeFree)/1gb,2))}},@{l='SizeSnapUsed(GB)';e={([math]::Round([decimal]($_.SizeSnapUsed)/1gb,2))}}} | export-csv H:\aggr.csv&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm new to powershell and noob in scripting. &amp;nbsp;Can somebody please help to get aggr size from multi filers and export it to a file in csv format?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thank you&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 04 Jun 2025 23:23:32 GMT</pubDate>
    <dc:creator>NAMAN</dc:creator>
    <dc:date>2025-06-04T23:23:32Z</dc:date>
    <item>
      <title>Get-NaAggrSpace from multiple filers are failing</title>
      <link>https://community.netapp.com/t5/Microsoft-Virtualization-Discussions/Get-NaAggrSpace-from-multiple-filers-are-failing/m-p/109416#M4485</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;foreach ($filer in Get-Content H:\7mode.txt)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;{ $c = Connect-NaController | Get-NaAggrSpace | select AggregateName,@{l='SizeFree(GB)';e={([math]::Round([decimal]($_.SizeFree)/1gb,2))}},@{l='SizeSnapUsed(GB)';e={([math]::Round([decimal]($_.SizeSnapUsed)/1gb,2))}}} | export-csv H:\aggr.csv&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm new to powershell and noob in scripting. &amp;nbsp;Can somebody please help to get aggr size from multi filers and export it to a file in csv format?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thank you&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 04 Jun 2025 23:23:32 GMT</pubDate>
      <guid>https://community.netapp.com/t5/Microsoft-Virtualization-Discussions/Get-NaAggrSpace-from-multiple-filers-are-failing/m-p/109416#M4485</guid>
      <dc:creator>NAMAN</dc:creator>
      <dc:date>2025-06-04T23:23:32Z</dc:date>
    </item>
    <item>
      <title>Re: Get-NaAggrSpace from multiple filers are failing</title>
      <link>https://community.netapp.com/t5/Microsoft-Virtualization-Discussions/Get-NaAggrSpace-from-multiple-filers-are-failing/m-p/109426#M4489</link>
      <description>&lt;P&gt;Hi Naman,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I see two problems with the PowerShell pipeline you created.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Connect-NaController has be to passed $filer as argument - unlike Perl PowerShell has no $_ that is automatically utilized. So Connect-NaController in your case did not know what controller to connect to. Since no connection was made, 'Get-NaAggrSpace' was failing with 'Object in $global:currentNaController' is not of correct type'.&lt;/LI&gt;&lt;LI&gt;Export-CSV has to be a part of the pipeline inside the for-loop. Putting Export-CSV outside the for means you're attempting to store the output of the foreach cmdlet (which is NULL. What you see on screen is output of the cmdlets &lt;EM&gt;inside&lt;/EM&gt; foreach and are no longer part of the pipeline).&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Fixing these two, adding a controller name to the output for ease of analysis and configuring RPC access on my 7-mode filers (if RPC does not work, you'll have to use HTTP/HTTPS &amp;amp; pass a Credential object to Connect-NaController), the script should look like this -&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;foreach ($filer in Get-Content H:\7mode.txt)
{ 
    
   $c = Connect-NaController $filer #-HTTPS -Credential $script_credential, in case RPC can not be used
   $rows = Get-NaAggrSpace | select AggregateName, @{l='SizeFree(GB)';e={([math]::Round([decimal]($_.SizeFree)/1gb,2))}}, @{l='SizeSnapUsed(GB)';e={([math]::Round([decimal]($_.SizeSnapUsed)/1gb,2))}} 
   
   foreach ($row in $rows) { 
    if ($row -ne $null) {
        #Creating an object so that Export-CSV can give a pretty output
        $output = New-Object –TypeName PSObject
        $output | Add-Member –MemberType NoteProperty –Name AggregateName –Value $row.AggregateName
        $output | Add-Member –MemberType NoteProperty –Name SizeFree –Value $row.'SizeFree(GB)'
        $output | Add-Member –MemberType NoteProperty –Name SizeSnapUsed –Value $row.'SizeSnapUsed(GB)'
        $output | Add-Member –MemberType NoteProperty –Name Controller –Value $global:CurrentNaController
   
        $output | Export-CSV H:\aggr.csv -Append
    }
   }&lt;/PRE&gt;&lt;P&gt;The output CSV was&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;#TYPE System.Management.Automation.PSCustomObject
"AggregateName","SizeFree","SizeSnapUsed","Controller"
"aggr0","0.15","0.03","10.63.4.208"
"aggr1","0.14","0.00","10.63.4.208"
"aggr2","0.16","0.00","10.63.4.208"
"aggr3","132.15","1.38","10.72.211.52"
"aggr0","7.28","1.08","10.72.211.52"&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>Fri, 04 Sep 2015 05:13:27 GMT</pubDate>
      <guid>https://community.netapp.com/t5/Microsoft-Virtualization-Discussions/Get-NaAggrSpace-from-multiple-filers-are-failing/m-p/109426#M4489</guid>
      <dc:creator>Aparajita</dc:creator>
      <dc:date>2015-09-04T05:13:27Z</dc:date>
    </item>
    <item>
      <title>Re: Get-NaAggrSpace from multiple filers are failing</title>
      <link>https://community.netapp.com/t5/Microsoft-Virtualization-Discussions/Get-NaAggrSpace-from-multiple-filers-are-failing/m-p/109444#M4491</link>
      <description>&lt;P&gt;Thank you soooo much for your prompt reply and solution. &amp;nbsp;I ran the script as below but I'm seeing only one aggr in the csv file although I have more than 10 filers. &amp;nbsp;When I run I don't see any errors either. &amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I removed this line as I can run the script without it.&lt;/P&gt;&lt;PRE&gt;$c = Connect-NaController $filer #-HTTPS -Credential $script_credential, in case RPC can not be used&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;foreach ($filer in Get-Content H:\7mode.txt)&lt;BR /&gt;{&lt;BR /&gt;&lt;BR /&gt;$rows = Get-NaAggrSpace | select AggregateName, @{l='SizeFree(GB)';e={([math]::Round([decimal]($_.SizeFree)/1gb,2))}}, @{l='SizeSnapUsed(GB)';e={([math]::Round([decimal]($_.SizeSnapUsed)/1gb,2))}}}&lt;BR /&gt;&lt;BR /&gt;foreach ($row in $rows) {&lt;BR /&gt;if ($row -ne $null) {&lt;BR /&gt;#Creating an object so that Export-CSV can give a pretty output&lt;BR /&gt;$output = New-Object –TypeName PSObject&lt;BR /&gt;$output | Add-Member –MemberType NoteProperty –Name AggregateName –Value $row.AggregateName&lt;BR /&gt;$output | Add-Member –MemberType NoteProperty –Name SizeFree –Value $row.'SizeFree(GB)'&lt;BR /&gt;$output | Add-Member –MemberType NoteProperty –Name Controller –Value $global:CurrentNaController&lt;BR /&gt;&lt;BR /&gt;$output | Export-CSV H:\aggr.csv -Append&lt;BR /&gt;}&lt;BR /&gt;}&lt;/P&gt;</description>
      <pubDate>Fri, 04 Sep 2015 11:35:31 GMT</pubDate>
      <guid>https://community.netapp.com/t5/Microsoft-Virtualization-Discussions/Get-NaAggrSpace-from-multiple-filers-are-failing/m-p/109444#M4491</guid>
      <dc:creator>NAMAN</dc:creator>
      <dc:date>2015-09-04T11:35:31Z</dc:date>
    </item>
    <item>
      <title>Re: Get-NaAggrSpace from multiple filers are failing</title>
      <link>https://community.netapp.com/t5/Microsoft-Virtualization-Discussions/Get-NaAggrSpace-from-multiple-filers-are-failing/m-p/109447#M4492</link>
      <description>&lt;P&gt;Hi Naman,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The reason you are getting output from only one controller is because you removed the `Connect-NcController $filer`from inside the loop. The Get-AggrSpace ends up being run against the same filer (which you are already connected to, before running the loop) 'n' times - n being the number of filers in 7mode.txt&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 04 Sep 2015 13:21:50 GMT</pubDate>
      <guid>https://community.netapp.com/t5/Microsoft-Virtualization-Discussions/Get-NaAggrSpace-from-multiple-filers-are-failing/m-p/109447#M4492</guid>
      <dc:creator>Aparajita</dc:creator>
      <dc:date>2015-09-04T13:21:50Z</dc:date>
    </item>
  </channel>
</rss>

