Cloud Articles and Resources

Discovery all your controllers and retrieve a specific piece of info from each one.

So my lab has a good number of controllers and my Boss walked in and wanted to know specifically where the FlexCache Cards we installed at located. Can I write a quick and dirty script to discover all the controllers in the lab, log onto each one using one of two default passwords, then find out if a FlexCache controller exists in each one.

An hour later this emerged. Its pretty rough, but it works well. I put in code to make sure the login was successful, as well as modified the output colors to make sure its fast to read the output.

function FindFlashDevice
   {    if (get-naflashdevice -erroraction silentlycontinue)
        {     $size=(get-naflashdevice).capacity/1024/1024/1024
              Write-host "Found a Flash Device of size "$size"GB." -foregroundcolor green
        }
       else
       {      write-host " - - No Flash Device Found" -foregroundcolor gray
       }
}

function ScanSubnet($IPAddr, $SubNetMask)
{     Write-host "Scanning Subnet "$IPAddr" with mask "$SubNetMask
      foreach($controller in find-nacontroller $IPAddr $SubNetMask)
      {     write-host " - Found Controller "$Controller.name
            if (Connect-NAController ($controller.address).ipaddresstostring –cred $cred1 -erroraction silentlycontinue)
           {      write-host " - - Connected using First Credentials" -foregroundcolor gray
                 FindFlashDevice
            }
           else
           {     if (Connect-NAController ($controller.address).ipaddresstostring –cred $cred2 -erroraction silentlycontinue)
                 {        write-host " - - Connected using second credentials" -foregroundcolor gray
                          FindFlashDevice
                 }
                 else
                {        write-host "Unable to connect to controller" -foregroundcolor red
                }
         }
    }
}

$pass1=ConvertTo-SecureString “secretpassword” –AsPlainText –Force
$pass2=ConvertTo-SecureString “othersecretpassword” –AsPlainText –Force
$cred1=New-Object –TypeName System.Management.Automation.PSCredential –Argumentlist “root”,$pass1
$cred2=New-Object –TypeName System.Management.Automation.PSCredential –Argumentlist “root”,$pass2

Write-host "---------------"
Write-host "Starting Script"
Write-host "---------------"

ScanSubnet "10.50.88.0" "255.255.255.0"
ScanSubnet "10.60.92.0" "255.255.252.0"
ScanSubnet "10.70.99.0" "255.255.255.0"

The output of the script looks like this.

I am sure I could do much more complex tasks, but this script shows how you can scan a farm of NetApp controllers.

Chris Lionetti

   
 
 
 
 
 
 
 
 
 
 
 





Please Note:

All content posted on the NetApp Community is publicly searchable and viewable. Participation in the NetApp Community is voluntary.

In accordance with our Code of Conduct and Community Terms of Use, DO NOT post or attach the following:

  • Software files (compressed or uncompressed)
  • Files that require an End User License Agreement (EULA)
  • Confidential information
  • Personal data you do not want publicly available
  • Another’s personally identifiable information (PII)
  • Copyrighted materials without the permission of the copyright owner

Continued non-compliance may result in NetApp Community account restrictions or termination.

All Community Forums