Powershell Commands for OnSite Support Activities : Part 1 of Troubleshooting Tools

by New Contributor on ‎2010-12-04 04:59 PM

This is the First of a multipart post with tools to help troubleshoot problems with an enviornment. By the time I have completed this series you should have a small toolkit of commands to troubleshoot specific problems.

I was troubleshooting some problems with a Cisco UCS deployment last week, and ran into some problems. The customer had Telnet, as well as filerview available to the controller we were troubleshooting, but we kept finding ourselves switching between the two to get the information we needed. We also ended up doing a lot more hunting and pecking for the exact telnet command to find out a specific piece of information. The problem was that a few of the Cisco Blades couldn't find their boot drives, and the customer had 6 controllers, so the number of windows we needed to have open and the repeated commands were painful.

This is kind of what powersell is best at. The end result was that we needed to check the following thing.

     1). Was the zoning to the switches set correctly so that the the HBA could see the correct ports?

          The Virtual HBA 1, was connected to Virtual Fabric 1, which then connected to two predefined ports on a controller.

          The first script was written to check this fact. In many cases we found that zoning was set incorrectly, and that the HBAs just couldn't see the contollers.

The prefered method to solve this problem is to log onto the Virtual Switch and check the zoning and check to see if the devices have logged into the name server, but we didn't have access And you all know storage is guilty until proven innocent. So the first script that I have copied below is to allow me check and see if an HBA is connected to a specific port on a controller. Mind you, this customer had 50ish HBAs connected to each contoller, and we dont want to search manually.

So this script works in the following way. Firstly, connect to the controller that you want to check using connect-nacontroller. Then run the command as follows.

     .\FindHBAOnPorts.ps1 "10:00:00:C9;34:34:54:45"

The script will connect to the controller and output if that world wide name is detected on the controller, and specifically which ports it has been found on.

Sample output looks like this.

PS C:\software\toolkit> .\FindHBAonPorts.ps1 "10:00:00:00:c9:6f:27:40"


You must send in a WWPN with double quotes around it
-Looking for WWPN 10:00:00:00:c9:6f:27:40--------------------------
Query Port  0a with WWPN 50:0a:09:81:98:7d:2e:52
      -------------------------------------
      +Found HBA 10:00:00:00:c9:6f:27:40
      ------------------------------------

Query Port  0b with WWPN 50:0a:09:82:98:7d:2e:52

PS C:\software\toolkit>

     

The script is as follows.

# This script takes the World Wide name listed in the variables and finds where
# that WWN is detected on the array via any of the ports
#  assume that you have already connected to the array you want to ingerrogate

param (
[parameter(position=0,mandatory=$true)]

$findthis )


 
write-host ""
Write-host "You must send in a WWPN with double quotes around it"
write-host ""
if ($findthis -eq "")
{ write-host "-Detected no passed WWN. Assuming you want a list of HBAs seen by target ports."
$listall=$true
}
else
{ Write-host "-Looking for WWPN"$findthis"--------------------------"
$listall=$false
}
write-host ""
$x = get-nafcpadapter
foreach ($port in $x)
{
  $PA = $PORT.ADAPTER
  $PN = $Port.Portname
  write-host "   Query Port "$pa" with WWPN "$PN
  $y = get-nafcpinitiator $PA
  $z=$y.fcpconnectedinitiators
  foreach ($nc in $z)
   {
    $test=$nc.portname
    if($listall)   
    { write-host "       -Detected HBA"$test "Logged in"
    }
    if($test -eq $findthis)
    { write-host "      -------------------------------------"
     Write-host "      +Found HBA"$findthis
     write-host "      -------------------------------------"
    }
   }
}
Write-host ""

I will post Script two early this coming week. Have fun Coding, and remember that powershell is supposed to give you more free time back, so have a beer and watch the game. If you are a fan of the Apple Cup..Go Cougs.

Warning!

This NetApp Community is public and open website that is indexed by search engines such as Google. Participation in the NetApp Community is voluntary. All content posted on the NetApp Community is publicly viewable and available. This includes the rich text editor which is not encrypted for https.

In accordance to 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
  • Copyrighted materials without the permission of the copyright owner

Files and content that do not abide by the Community Terms of Use or Code of Conduct will be removed. Continued non-compliance may result in NetApp Community account restrictions or termination.