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

by New Contributor on ‎2010-12-11 10:20 PM

New day, New Script. These thing are fast and easy to put together, and they save quite a bit of time on site. This script is all about making sure that the Licenses match between the two controllers that make up a HA pair.

The script does just that. It is very similar to the previous script in the sense that you add the credentials to the begining of the script and let it run against the pair of controllers. The Script shows any licenses that exist on the A controller that dont exist on the B controller and vice-versa. If you run the tool with no arguments, it will simply tell you what licenses dont match. If you use the Verbose mode, it will list all licenses on both controllers as well, or if you run it in Execute mode, it will actually run the commands for you and make them match. Below I show the output only of the normal mode,

Methods to Run the Program

PowerShell Prompt> .\LicenseChecker.ps1               <- Normal Mode

PowerShell Prompt> ,\LicenseChecker.ps1 "Verbose"    <- Verbose Mode

PowerShell Prompt> .\LicenseChecker.ps1 "Execute"     <- Execute Mode

Script Output

PS C:\software\toolkit> .\LicenseMatcher.ps1

Name                 Address           Ontapi   Version
----                 -------           ------   -------
10.58.99.254         10.58.99.254      1.11     NetApp Release 8.0 7-Mode: Thu Mar 11 16:10:16 PST 2010
10.58.99.253         10.58.99.253      1.11     NetApp Release 8.0 7-Mode: Thu Mar 11 16:10:16 PST 2010
------------------------------------------------
Execute with quotes around it was not detected.
   Only showing the changes that need to be made to the second controller to match the first controller.
Verbose with quotes around it was not detected.
   Showing All settings on current controller as well as mismatches on the second controller
------------------------------------------------
   A Sides    =  nfs = ABCDEFG
                Connect to the  10.58.99.254 controller and use following command to fix;
        add-nalicense ABCDEFG
   B Side     =  snapmanagerexchange = STUVWXYZ
                Connect to the  10.58.99.253 controller and use following command to fix;
        add-nalicense STUVWXYZ
   B Side     =  snaprestore = EIEIO..
                Connect to the  10.58.99.253 controller and use following command to fix;
        add-nalicense EIEIO..


PS C:\software\toolkit>

Sample Code

# This script will connect to a set of Storage Controllers and retreive all
# of the License Setttings. It will then connect to a second (partner)
# controller and compair those settings. The recommended changes will be shown.

param ([parameter(position=0)] $Argument )

$AController = "10.58.99.254"
$BController = "10.58.99.253"
$User = "administrator"
$Pass = "Password"


$ACPass  = ConvertTo-SecureString $Pass -AsPlainText –Force
$Acred = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $User,$ACPass
$BCPass  = ConvertTo-SecureString $Pass -AsPlainText –Force
$Bcred = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $User,$BCPass

Connect-NaController $AController -Credential $Acred
$Aops = get-nalicense

Connect-NaController $BController -Credential $Bcred
$Bops = get-nalicense

Write-host "------------------------------------------------"
if ($argument -ne "Execute")
{ Write-host "Execute with quotes around it was not detected."
  Write-host "   Only showing the changes that need to be made to the second controller to match the first controller."
}
if ($argument -ne "Verbose")
{ Write-host "Verbose with quotes around it was not detected."
  Write-host "   Showing All settings on current controller as well as mismatches on the second controller"
}

Write-host "------------------------------------------------"
foreach ($Alic in $Aops)
{ foreach($Blic in $Bops)
{ if ($Blic.service -eq $Alic.service)
  { if ($Blic.islicensed -or $Alic.islicensed)
   { if ($alic.islicensed)
    { if ($blic.islicensed)
     { if ($argument -eq "Verbose")
      { write-host "   Both Sides = "$Alic.service"="$alic.code
      }     
     }
     else
     { write-host "   A Sides    = "$Alic.service"="$Alic.code
      if ($argument -eq "Execute")
      { write-host "        Connecting to Controller and adding license"
       $suppress = Connect-NaController $BController -Credential $Bcred
       $suppress = add-nalicense $alic.code
      }
      else
      { write-host "  Connect to the "$acontroller" controller and use following command to fix;"
       write-host "        add-nalicense"$alic.code
      }
     }
    }
    else
    {     write-host "   B Side     = "$Blic.service"="$Blic.code
      if ($argument -eq "Execute")
      { write-host "        Connecting to Controller and adding license"
       $suppress = Connect-NaController $AController -Credential $Acred
       $suppress = add-nalicense $Blic.code
      }
      else
      { write-host "  Connect to the "$bcontroller" controller and use following command to fix;"
       write-host "        add-nalicense"$blic.code
      }
    }
   }
  }
}
}

Have a great weekend everyone, and Happy Coding.

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.