<?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: question about filtering results in Microsoft Virtualization Discussions</title>
    <link>https://community.netapp.com/t5/Microsoft-Virtualization-Discussions/question-about-filtering-results/m-p/50351#M2332</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If you're looking to store the command in a script, I would recommend using a more formal command structure.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Get-NaDisk | ? {$_.RaidState -NE "partner"} | sort DiskType | ft DiskType,Aggregate,RaidState -AutoSize&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Becomes...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Get-NaDisk | Where-Object {$_.RaidState -ne "partner"} | Sort-Object -Property DiskType | Format-Table -Property DiskType,Aggregate,RaidState -AutoSize&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you want to re-use any of the intermediate states, you can also use variables.&amp;nbsp; Storing intermediate values in variables can also be helpful in troubleshooting errors in your scripts.&amp;nbsp; Also, if you want to include comments, they are preceded with the # character.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;#Get a list of all disks&lt;/P&gt;&lt;P&gt;$allDisks = Get-NaDisk&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;#Filter out partner disks&lt;/P&gt;&lt;P&gt;$nonpartnerDisks = $allDisks | Where-Object {$_.RaidState -ne "partner"}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;#Sort the list of non-partner disks&lt;/P&gt;&lt;P&gt;$sortedNonpartnerDisks = $nonpartnerDisks = $allDisks | Sort-Object -Property DiskType&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;#Output the data is a formatted table showing the disk type, aggregate, and raidstate&lt;/P&gt;&lt;P&gt;$sortedNonpartnerDisks | Format-Table -Property DiskType,Aggregate,RaidState -AutoSize&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Happy scripting!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 01 Oct 2010 20:40:30 GMT</pubDate>
    <dc:creator>paleon</dc:creator>
    <dc:date>2010-10-01T20:40:30Z</dc:date>
    <item>
      <title>question about filtering results</title>
      <link>https://community.netapp.com/t5/Microsoft-Virtualization-Discussions/question-about-filtering-results/m-p/50335#M2327</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am very new to Powershell, and coding as a whole, and have really only begun to realize what it can do for me. I am new to the company I'm working for as well, and one thing they are lacking is Operations Manager, or any real reporting tool. I've begun to try to use PS for this. I've been successful at some scripts but one thing I wanted to do was to create a list of disks, which aggr they are assigned to, as well as the raid state. I've entered this command &lt;STRONG style="color: #ff0000; "&gt;get-nadisk | ft disktype,aggregate,raidstate -auto&lt;/STRONG&gt; &lt;SPAN style="color: #000000;"&gt;to get this output (just a sample):&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #ff0000;"&gt;DiskType Aggregate&amp;nbsp;&amp;nbsp; RaidState&lt;BR /&gt;--------&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ---------&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ---------&lt;BR /&gt;FCAL&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; spare&lt;BR /&gt;ATA&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; partner&lt;BR /&gt;ATA&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; partner&lt;BR /&gt;ATA&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; partner&lt;BR /&gt;ATA&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sata0&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; present&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What I want to be able to do is write a script that will omit the "partner" disks and only show the present and spare disks. I was thinking that a "where" statement might work, but then I'm thinking that will only pull one of the 3 raid states. Then I was thinking I might want to further sort FC and SATA disks as well as present or partner and my head started to spin. How would I go about filtering down my results? If I do use a "where" statement, what property would I use to define the RaidState column?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Aaron&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 05 Jun 2025 07:07:37 GMT</pubDate>
      <guid>https://community.netapp.com/t5/Microsoft-Virtualization-Discussions/question-about-filtering-results/m-p/50335#M2327</guid>
      <dc:creator>smith_aaron</dc:creator>
      <dc:date>2025-06-05T07:07:37Z</dc:date>
    </item>
    <item>
      <title>Re: question about filtering results</title>
      <link>https://community.netapp.com/t5/Microsoft-Virtualization-Discussions/question-about-filtering-results/m-p/50340#M2328</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Get-NaDisk | &lt;SPAN style="color: #0000ff;"&gt;? {$_.RaidState -NE "partner"}&lt;/SPAN&gt; | &lt;SPAN style="color: #ff0000;"&gt;sort DiskType&lt;/SPAN&gt; | ft DiskType,Aggregate,RaidState -AutoSize&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 01 Oct 2010 19:03:57 GMT</pubDate>
      <guid>https://community.netapp.com/t5/Microsoft-Virtualization-Discussions/question-about-filtering-results/m-p/50340#M2328</guid>
      <dc:creator>cknight</dc:creator>
      <dc:date>2010-10-01T19:03:57Z</dc:date>
    </item>
    <item>
      <title>Re: question about filtering results</title>
      <link>https://community.netapp.com/t5/Microsoft-Virtualization-Discussions/question-about-filtering-results/m-p/50348#M2330</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Awesome, thanks! I think I'm going to read up on Powershell this weekend...&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 01 Oct 2010 19:09:39 GMT</pubDate>
      <guid>https://community.netapp.com/t5/Microsoft-Virtualization-Discussions/question-about-filtering-results/m-p/50348#M2330</guid>
      <dc:creator>smith_aaron</dc:creator>
      <dc:date>2010-10-01T19:09:39Z</dc:date>
    </item>
    <item>
      <title>Re: question about filtering results</title>
      <link>https://community.netapp.com/t5/Microsoft-Virtualization-Discussions/question-about-filtering-results/m-p/50351#M2332</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If you're looking to store the command in a script, I would recommend using a more formal command structure.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Get-NaDisk | ? {$_.RaidState -NE "partner"} | sort DiskType | ft DiskType,Aggregate,RaidState -AutoSize&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Becomes...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Get-NaDisk | Where-Object {$_.RaidState -ne "partner"} | Sort-Object -Property DiskType | Format-Table -Property DiskType,Aggregate,RaidState -AutoSize&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you want to re-use any of the intermediate states, you can also use variables.&amp;nbsp; Storing intermediate values in variables can also be helpful in troubleshooting errors in your scripts.&amp;nbsp; Also, if you want to include comments, they are preceded with the # character.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;#Get a list of all disks&lt;/P&gt;&lt;P&gt;$allDisks = Get-NaDisk&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;#Filter out partner disks&lt;/P&gt;&lt;P&gt;$nonpartnerDisks = $allDisks | Where-Object {$_.RaidState -ne "partner"}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;#Sort the list of non-partner disks&lt;/P&gt;&lt;P&gt;$sortedNonpartnerDisks = $nonpartnerDisks = $allDisks | Sort-Object -Property DiskType&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;#Output the data is a formatted table showing the disk type, aggregate, and raidstate&lt;/P&gt;&lt;P&gt;$sortedNonpartnerDisks | Format-Table -Property DiskType,Aggregate,RaidState -AutoSize&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Happy scripting!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 01 Oct 2010 20:40:30 GMT</pubDate>
      <guid>https://community.netapp.com/t5/Microsoft-Virtualization-Discussions/question-about-filtering-results/m-p/50351#M2332</guid>
      <dc:creator>paleon</dc:creator>
      <dc:date>2010-10-01T20:40:30Z</dc:date>
    </item>
  </channel>
</rss>

