Why I needed this

I received a call from a technician in another site one day to let me know that we had 3 amber lights in our NetApp cluster. While autosupport should have caught this, it didn't (one controller showed them pre-failed, and the other showed them as failed disks).

So I turned to my love of PowerShell and added to the NetApp functions I wrote that perform actions when connected to NetApp controllers. If you haven't seen those posts, check them out!

How to use this

You'll need to first be connected to a NetApp controller and have the NetApp PowerShell module installed. Once that part is completed, you can use the code below. I also like to set a global variable for $foregroundColor, and this script utilizes that.

The Code

$netAppSystemInfo = Get-NCNode

        Write-Host `n"Controller information (CDOT)"`n -ForegroundColor $foregroundColor

        foreach ($node in $netappSystemInfo) {
            
            Write-Host "Node" $node.Node ` -foregroundcolor $foregroundcolor
            Write-Host "Model   :" $node.NodeModel
            Write-Host "Serial #:" $node.NodeSerialNumber
            Write-Host "Location:" $node.NodeLocation
            Write-Host "Healthy?:" $node.IsNodeHealthy
            Write-Host "Uptime  :" $node.NodeUptime
            Write-Host "ONTAPver:" $node.ProductVersion `n
            
        }
$failedDisks = Get-NcDisk | ?{ $_.DiskRaidInfo.ContainerType -eq "broken" }
        
        if ($failedDisks) {
        
            Write-Host `n"There are failed disks on this NetApp cluster!" -foregroundColor Red
            Write-Host "Failed Disks:"`n -foregroundColor $foregroundcolor
            
            foreach ($disk in $failedDisks){
                
                Write-Host "Disk Name      :" $disk.DiskName
                Write-Host "Disk UID       :" $disk.DiskUID
                Write-Host "Disk Controller:" $disk.NcController
                Write-Host "Disk Bay       :" $disk.Bay
                Write-Host "Disk Shelf     :" $disk.Shelf
                Write-Host "Disk model/FW  :" $disk.Model "/" $disk.FW `n
                
                
            }
            
            $openCase = Read-Host "Would you like to open a support case?"
            if ($openCase -like "*y*") {
                
                Start-Process "http://mysupport.netapp.com/cssportal/faces/oracle/webcenter/portalapp/pages/css/casesparts/CreateCaseLanding.jspx?_adf.no-new-window-redirect=true"
                
            }
            
        }
        
        
        $unOwnedDisks =  get-NCDisk
        
        foreach ($d in $unOwnedDisks) { 

            if ($d.diskownershipinfo.OwnerNodeName -eq $null) {
                
                Write-Host `n"Unowned disks found!" -foregroundColor Red
                Write-Host "Unowned Disks:"`n -foregroundcolor $foregroundColor
                Write-Host "Disk Name:" $d.DiskName
                
                $setOwner = Read-Host "Set owner to one of the nodes in the cluster?"
                
                if ($setOwner -like "*y*") {
                    
                    $i = 0 
                    foreach ($node in $netAppSystemInfo) {
                        
                        Write-Host $i -> "Node:" $node.Node
                        $i++
                    
                }
                
                $node = Read-Host "Which node #?"
                $nodeSystemID = $netAppSystemInfo[$node].NodeSystemID
                $nodeName = $netAppSystemInfo[$node].node
                $diskname = $d.DiskName
                $confirm = Read-Host "Set disk owner for disk $diskName to:" $nodeName "with systemID" $nodeSystemID"?"
                
                if ($confirm -like "*y*") {
                    
                    Set-NCDiskOwner -DiskName $diskName -NodeId $nodeSystemID
                    
                }
                    
                    
                    
                }

            } 
        
    
        }

What it will do

It will hunt down any failed or unowned disks. It will then prompt you to open the support page to open a new case. If it finds any unowned disks, it will give you the option to assign them to the controller of your choice.

As always, let me know if you have any feedback!

-Ginger Ninja