Microsoft Virtualization Discussions

Spare disk count not working

thepunisher
6,812 Views

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
6,812 Views

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
6,812 Views

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

thepunisher
6,812 Views

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
6,813 Views

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.

thepunisher
6,812 Views

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

cknight
6,812 Views

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
6,812 Views

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
6,812 Views

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

Public