<?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: foreach from file not working in Microsoft Virtualization Discussions</title>
    <link>https://community.netapp.com/t5/Microsoft-Virtualization-Discussions/foreach-from-file-not-working/m-p/27563#M1235</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The way you are saving filer names in filers.txt is wrong, you need to append them as below&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG src="http://community.netapp.com/legacyfs/online/21653_filers.png" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 17 Jun 2013 17:17:58 GMT</pubDate>
    <dc:creator>vinith</dc:creator>
    <dc:date>2013-06-17T17:17:58Z</dc:date>
    <item>
      <title>foreach from file not working</title>
      <link>https://community.netapp.com/t5/Microsoft-Virtualization-Discussions/foreach-from-file-not-working/m-p/27558#M1234</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I created a script to show aggregates more than 90% full on multiple filers but they would not connect&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;the text file is like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;"filer1", "filer2", "filer3"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;+++++++++++++++++++++++++++++++++++++++++++++++++++&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;$ntapArrays = (get-content "C:\filers.txt")&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;$FasUser = "root"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;$FasPasswd = Read-Host "Enter password"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;$SecureFasPasswd = ConvertTo-SecureString $FasPasswd -AsPlainText -Force&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;$FasCred = New-Object -TypeName System.Management.Automation.PSCredential ($FasUser, $SecureFasPasswd)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; Foreach ($array in $ntapArrays) {&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;connect-nacontroller -Name $array -Credential $FasCred&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; Get-Naaggr | select homename, SizePercentageUsed, name | ? {$_.SizePercentageUsed -gt 90} | ft -AutoSize&lt;/P&gt;&lt;P&gt; }&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;++++++++++++++++++++++++++++++++++++++++++++++&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;the error messages is &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Connect-NaController : Cannot bind argument to parameter 'Name' because it is a&lt;/P&gt;&lt;P&gt;n empty string.&lt;/P&gt;&lt;P&gt;At C:\script2.ps1:30 char:27&lt;/P&gt;&lt;P&gt;+ connect-nacontroller -Name &amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;nbsp; $array -Credential $FasCred&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; + CategoryInfo&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; : InvalidData&amp;amp;colon; (:) [Connect-NaController], Paramet&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; erBindingValidationException&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; + FullyQualifiedErrorId : ParameterArgumentValidationErrorEmptyStringNotAl&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; lowed,DataONTAP.PowerShell.SDK.ConnectNaController&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;what am I doing wrong?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cheers&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 05 Jun 2025 06:00:30 GMT</pubDate>
      <guid>https://community.netapp.com/t5/Microsoft-Virtualization-Discussions/foreach-from-file-not-working/m-p/27558#M1234</guid>
      <dc:creator>JSHACHER11</dc:creator>
      <dc:date>2025-06-05T06:00:30Z</dc:date>
    </item>
    <item>
      <title>Re: foreach from file not working</title>
      <link>https://community.netapp.com/t5/Microsoft-Virtualization-Discussions/foreach-from-file-not-working/m-p/27563#M1235</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The way you are saving filer names in filers.txt is wrong, you need to append them as below&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG src="http://community.netapp.com/legacyfs/online/21653_filers.png" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 17 Jun 2013 17:17:58 GMT</pubDate>
      <guid>https://community.netapp.com/t5/Microsoft-Virtualization-Discussions/foreach-from-file-not-working/m-p/27563#M1235</guid>
      <dc:creator>vinith</dc:creator>
      <dc:date>2013-06-17T17:17:58Z</dc:date>
    </item>
    <item>
      <title>Re: foreach from file not working</title>
      <link>https://community.netapp.com/t5/Microsoft-Virtualization-Discussions/foreach-from-file-not-working/m-p/27570#M1236</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;OK, the Controllers are connecting now but I still don't get the aggregates info. Something is wrong here:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; Foreach ($array in $ntapArrays) {&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;connect-nacontroller -Name $array -Credential $FasCred&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; Get-Naaggr | select homename, SizePercentageUsed, name | ? {$_.SizePercentageUsed -gt 90} | ft -AutoSize&lt;/P&gt;&lt;P&gt; }&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 17 Jun 2013 17:50:00 GMT</pubDate>
      <guid>https://community.netapp.com/t5/Microsoft-Virtualization-Discussions/foreach-from-file-not-working/m-p/27570#M1236</guid>
      <dc:creator>JSHACHER11</dc:creator>
      <dc:date>2013-06-17T17:50:00Z</dc:date>
    </item>
    <item>
      <title>Re: foreach from file not working</title>
      <link>https://community.netapp.com/t5/Microsoft-Virtualization-Discussions/foreach-from-file-not-working/m-p/27575#M1237</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Joel,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Instead of &lt;STRONG&gt;"filer1", "filer2", "filer3" &lt;/STRONG&gt;save your txt as &lt;STRONG&gt;filer1,filer2,filer3&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;You can do it this way :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;$ntapArrays = (get-content "C:\filers.txt")&lt;/P&gt;&lt;P&gt;$ntapArrays = $filertxt.Split(',')&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Foreach ($array in $ntapArrays) {&lt;/P&gt;&lt;P&gt;...&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 17 Jun 2013 17:51:52 GMT</pubDate>
      <guid>https://community.netapp.com/t5/Microsoft-Virtualization-Discussions/foreach-from-file-not-working/m-p/27575#M1237</guid>
      <dc:creator>KARL_BUSTAMANTE</dc:creator>
      <dc:date>2013-06-17T17:51:52Z</dc:date>
    </item>
    <item>
      <title>Re: foreach from file not working</title>
      <link>https://community.netapp.com/t5/Microsoft-Virtualization-Discussions/foreach-from-file-not-working/m-p/27583#M1238</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;OK, the Controllers are connecting now but I still don't get the aggregates info. Something is wrong here:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; Foreach ($array in $ntapArrays) {&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;connect-nacontroller -Name $array -Credential $FasCred&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; Get-Naaggr | select homename, SizePercentageUsed, name | ? {$_.SizePercentageUsed -gt 90} | ft -AutoSize&lt;/P&gt;&lt;P&gt; }&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 17 Jun 2013 17:54:03 GMT</pubDate>
      <guid>https://community.netapp.com/t5/Microsoft-Virtualization-Discussions/foreach-from-file-not-working/m-p/27583#M1238</guid>
      <dc:creator>JSHACHER11</dc:creator>
      <dc:date>2013-06-17T17:54:03Z</dc:date>
    </item>
    <item>
      <title>Re: foreach from file not working</title>
      <link>https://community.netapp.com/t5/Microsoft-Virtualization-Discussions/foreach-from-file-not-working/m-p/27588#M1239</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The easiest thing to do here is to list them in a text file as stated above&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;filer1&lt;/P&gt;&lt;P&gt;filer2&lt;/P&gt;&lt;P&gt;filer3&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then just do &lt;/P&gt;&lt;P&gt;$filers = gc c:\filers.txt &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;That will create the array &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then just put that array into a loop&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;$filers | % {&lt;/P&gt;&lt;P&gt;$c = connect-nacontroller $_ &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Put code here&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Also, you are doing something wrong in my opinion.&amp;nbsp; You need to put your where clause before your select statement.&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Get-Naaggr |&amp;nbsp; ? {$_.SizePercentageUsed -gt 90}| select homename, SizePercentageUsed, name |&amp;nbsp; | ft -AutoSize&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 17 Jun 2013 17:55:02 GMT</pubDate>
      <guid>https://community.netapp.com/t5/Microsoft-Virtualization-Discussions/foreach-from-file-not-working/m-p/27588#M1239</guid>
      <dc:creator>JGPSHNTAP</dc:creator>
      <dc:date>2013-06-17T17:55:02Z</dc:date>
    </item>
    <item>
      <title>Re: foreach from file not working</title>
      <link>https://community.netapp.com/t5/Microsoft-Virtualization-Discussions/foreach-from-file-not-working/m-p/27596#M1240</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;What is the output of &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="java" __jive_macro_name="code" class="jive_text_macro jive_macro_code _jivemacro_uid_13714921039592537" jivemacro_uid="_13714921039592537"&gt;&lt;P&gt;Get-NaAggr | select homename,SizePercentageUsed,name | ft -AutoSize&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can you confirm that you do have aggregates whose SizePercentageUsed is greater than 90?&lt;SPAN style="color: rgba(0, 0, 0, 0); font-size: 12px; font-family: helvetica, arial;"&gt;SizePercentageUsed is greater than 90?&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 17 Jun 2013 17:58:10 GMT</pubDate>
      <guid>https://community.netapp.com/t5/Microsoft-Virtualization-Discussions/foreach-from-file-not-working/m-p/27596#M1240</guid>
      <dc:creator>vinith</dc:creator>
      <dc:date>2013-06-17T17:58:10Z</dc:date>
    </item>
    <item>
      <title>Re: foreach from file not working</title>
      <link>https://community.netapp.com/t5/Microsoft-Virtualization-Discussions/foreach-from-file-not-working/m-p/27600#M1241</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Vinith, you were right. That list didn't have aggregate with more than 90%&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 17 Jun 2013 18:06:29 GMT</pubDate>
      <guid>https://community.netapp.com/t5/Microsoft-Virtualization-Discussions/foreach-from-file-not-working/m-p/27600#M1241</guid>
      <dc:creator>JSHACHER11</dc:creator>
      <dc:date>2013-06-17T18:06:29Z</dc:date>
    </item>
    <item>
      <title>Re: foreach from file not working</title>
      <link>https://community.netapp.com/t5/Microsoft-Virtualization-Discussions/foreach-from-file-not-working/m-p/27605#M1242</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you all - I will apply the advices&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 17 Jun 2013 18:06:59 GMT</pubDate>
      <guid>https://community.netapp.com/t5/Microsoft-Virtualization-Discussions/foreach-from-file-not-working/m-p/27605#M1242</guid>
      <dc:creator>JSHACHER11</dc:creator>
      <dc:date>2013-06-17T18:06:59Z</dc:date>
    </item>
    <item>
      <title>Re: foreach from file not working</title>
      <link>https://community.netapp.com/t5/Microsoft-Virtualization-Discussions/foreach-from-file-not-working/m-p/27609#M1243</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank You For letting us know that &lt;SPAN __jive_emoticon_name="happy" __jive_macro_name="emoticon" class="jive_macro jive_emote" src="https://community.netapp.com/5.0.1/images/emoticons/happy.gif"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 17 Jun 2013 18:08:41 GMT</pubDate>
      <guid>https://community.netapp.com/t5/Microsoft-Virtualization-Discussions/foreach-from-file-not-working/m-p/27609#M1243</guid>
      <dc:creator>vinith</dc:creator>
      <dc:date>2013-06-17T18:08:41Z</dc:date>
    </item>
    <item>
      <title>Re: foreach from file not working</title>
      <link>https://community.netapp.com/t5/Microsoft-Virtualization-Discussions/foreach-from-file-not-working/m-p/27613#M1244</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Joel - &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What your doing will look good if you want to stare at the screen - But you do you really want to do that.&amp;nbsp; Powershell is all about automation.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You want to have this as a scheduled tasks that emails you a report.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So, here's the basics.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;$globalarray = @()&lt;/P&gt;&lt;P&gt;$filers | % {&lt;BR /&gt;$filer = $_&lt;BR /&gt;$c = connet-nacontroller $filer&lt;/P&gt;&lt;P&gt;$aggr = get-naaggr | ? {$_.SizePercentageUsed -gt 10}&lt;/P&gt;&lt;P&gt;if ($aggr -ne $NUll) {&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $aggr | % {&lt;BR /&gt;&amp;nbsp; $customobject = new-object psobject&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Add-Member -inputobject $customobject -membertype Noteproperty -name filer -value $filer&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Add-Member -inputobject $customobject -membertype Noteproperty -name "Aggr" -value $_.name &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Add-Member -inputobject $customobject -membertype Noteproperty -name "total size" -value (convertto-formattednumber $_.totalsize datasize "0.0")&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Add-Member -inputobject $customobject -membertype Noteproperty -name "% used" -value (convertto-formattednumber $_.used percent)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; $globalarray += $customobject&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR /&gt;&amp;nbsp;&amp;nbsp; }&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; $globalarray | ft -autosize&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp; $globalarray | export-csv c:\temp\aggrereport.csv -notypeinformation.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Do some reading on custom objects and see if you can come up with sending this report to you..&amp;nbsp; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 17 Jun 2013 18:17:26 GMT</pubDate>
      <guid>https://community.netapp.com/t5/Microsoft-Virtualization-Discussions/foreach-from-file-not-working/m-p/27613#M1244</guid>
      <dc:creator>JGPSHNTAP</dc:creator>
      <dc:date>2013-06-17T18:17:26Z</dc:date>
    </item>
  </channel>
</rss>

