Microsoft Virtualization Discussions

Spare disk count not working

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


Re: Spare disk count not working

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

Re: Spare disk count not working

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

Re: Spare disk count not working

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

Re: Spare disk count not working

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

Re: Spare disk count not working

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.

Re: Spare disk count not working

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



Re: Spare disk count not working

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

Cloud Volumes ONTAP
Review Banner
All Community Forums