Microsoft Virtualization Discussions

Spare disk count not working

thepunisher

The NetApp that I am running this against has a single spare in it.  Why does this command not return any data?  It works accurately when I run it against systems with more spares.  I don't think is a zero based issue because the count is accurate on all our other systems.

(Get-NaDisk -controller $controller | Where-Object {$_.status -eq 'spare'}).count

1 ACCEPTED SOLUTION

cknight

OK, try this:

PS C:\> Get-NaDisk -controller $controller | Where-Object {$_.status -eq 'spare'} | Measure-Object

Count    : 151

Average  :

Sum      :

Maximum  :

Minimum  :

Property :

You might also try Confirm-NaAggrSpareLow to quickly find systems with insufficient spares.

View solution in original post

7 REPLIES 7

cknight

What is the reported status for the disk you know to be a spare?

thepunisher

Here is the results of the Get-NaDisk;

PS C:\Scripts> Get-NaDisk | Where-Object {$_.status -eq 'spare'}

Name            Shelf Bay Status     UsedSpace PhysSpace  RPM  FW    Model             Pool  Aggregate

----            ----- --- ------     --------- ---------  ---  --    -----             ----  ---------

0b.22             1    6  spare         266 GB    268 GB  10k  NA03  X276_HPYTA288F10    0

cknight

OK, try this:

PS C:\> Get-NaDisk -controller $controller | Where-Object {$_.status -eq 'spare'} | Measure-Object

Count    : 151

Average  :

Sum      :

Maximum  :

Minimum  :

Property :

You might also try Confirm-NaAggrSpareLow to quickly find systems with insufficient spares.

View solution in original post

thepunisher

That provides the correct result.  What's the difference between the commands?

cknight

Since you only have one spare, PowerShell treats the output as a single object rather than a collection, so there isn't a "count" method.  Measure-Object is a great way to count or otherwise measure the object(s) piped into it.

thepunisher

I thought I'd share what I finished with.  I doubt the drive count is the most elegant solution but it works for me.  I wanted to loop through the filers and get a count of all the spares on each system.  Here is the code;

$xmldata = [xml](get-content c:\scripts\data_files\netapps.xml)

$filers = $xmldata.netapps.filer | select name

 

foreach ($a in $filers)

          {

                    trap{"Error connection to " + $a.NAME}

                    $controller = Connect-NaController $a.NAME

 

                    Write-Host $controller, (Get-NaDisk -controller $controller | Where-Object {$_.status -eq 'spare'} | Measure-Object).count

 

          }

timothyn

Nice toolkit usage!

Another trick I use for disk inventory is using Group-Object (aka group) cmdlet:

PS C:\> get-nadisk | group Status | ft Name, Count -auto

Name    Count

----    -----

partner   207

dparity     2

spare     151

parity      5

data       25

Announcements
NetApp on Discord Image

We're on Discord, are you?

Live Chat, Watch Parties, and More!

Explore Banner

Meet Explore, NetApp’s digital sales platform

Engage digitally throughout the sales process, from product discovery to configuration, and handle all your post-purchase needs.

NetApp Insights to Action
I2A Banner
Public