Microsoft Virtualization Discussions

powershell script to find failed disks



I'm looking for a powershell script that access to multiple filers and find failed disks on them automatically then display the disks on the terminal or ideally send the info via email.

I think I can write a script using Get-NaDisk cmdlet. But sorry I'm lazy. If anyone has already created, could you share it with me?

I want to run the script first thing in the morning during I'm checking email over coffee. Then open a service request to get the failed disk replaced.

Thank you in advance




I'm all for writing scripts, but this is something Oncommand should be doing.  

Remember, you are never going to compete with developers especially with a program like oncommand..

But, if you insist, I will get you started

Put all the filers in a txt filer

$filers = gc c:\filers.txt

$filers | % {
$filer = $_

# Assuming you have RPC access to filer, if not you need to create credentials cache

$c = connect-nacontroller $filer

$disks = get-nadisk | ? {$_.status -eq "failed"}

# write to file

$disks | ? {$_.status -eq "failed"} | ft @{e={$Filer};l="filer";Width =10},@{e={$};L="Disk Name";Width=10},@{E={$_.status};L="Status";Width=10} | out-file c:\filer.log -append


if (gc c:\filer.log -ne $Null) {

Send-MailMessage -To $recipients -From $sendMailAs  -Subject $subjectLine -Body "Failed Disks attached" -Priority $priority -SmtpServer $smtpServer


# Please note, I wrote this really quick and dirty and I didn't even test it out..  I didn't have a failed disk to check to see if the status was failed or broken But it gives you different options on how to do things



I finally got a failed disk in my environment and tested the script.

One thing I have to change was the following line. A failed disk status shows "broken" instead of "failed". Then the failed disk info was output to c:\filer.log.  It's useful script for me. Thanks a lot!

$disks = get-nadisk | ? {$_.status -eq "failed"}


Yeah, I couldn't remember if it was failed or broken.   But glad you got it..

But, you really should be using SNMP MIBS or OCUM for this.    Why are you not doing that?



Yes, I am using SNMP MIBS and OCUM. A failed disk alert message is sent by email. When a failed disk alert mail is sent, each county's staff opens a service request ticket.

Our environment extendes across several countries. Since disk replacement completion is not sent to me, unless I login to the filer or login to the OnCommand system console, I can't check if the disk is replaced.  In order to check which failed disk is not replaced yet, I created the script.




Thank you for the script. I modified a bit and ran it.

Ah, I don't have a failed disk in my environment, it didn't catch anything. But no error occurred. I'll test with the script when I have a failed disk.

Thank you so much.


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.