Query a bunch of controllers

I got a question yesterday about querying 180 controllers for some specific CIFS information and sent over the following as one approach to automating the task.

 

I created the following XML file to use as my main source for the controller information. You'll notice in the XML file I am storing the password in cleartext which obviously isn't a best practice, but for my purposes here it works out the easiest.

 

<?xml version="1.0" encoding="utf-8"?>

<NetApp>

  <Controllers>

    <Controller>

      <IP>10.58.95.206</IP>

      <Login>admin</Login>

      <Password>somepassword</Password>

    </Controller>

    <Controller>

      <IP>10.58.95.207</IP>

      <Login>admin</Login>

      <Password>somepassword</Password>

    </Controller>

    <Controller>

      <IP>10.58.95.208</IP>

      <Login>admin</Login>

      <Password>somepassword</Password>

    </Controller>

  </Controllers>

</NetApp>

 

Simple PowerShell script to load the content from XML file iterate through the elements and then perform a Data ONTAP PowerShell cmdlet on each individual controller. In this example I'm querying CIFS looking for the ipc$ share, but you can change this to whatever cmdlet you want to execute.

 

cls

[xml]$controllers = Get-Content C:\temp\Controllers.xml

 

Foreach ($controller in $controllers.NetApp.Controllers.Controller)

{

  $IP = $controller.IP

  $login = $controller.Login

  $pwd = $controller.Password

 

  $password = ConvertTo-SecureString $pwd -AsPlainText -Force

  $cred = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $login, $password

 

  Connect-NcController $IP -Credential $cred -HTTPS

  Get-NcCifsShare | Where-Object {$_.ShareName -eq "ipc$"} | Format-Table Acl, ShareName, Volume, Path

}

 

Happy Long Weekend!

Barkz (aka NaSharePointGuy)