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

by New Contributor on ‎2010-12-09 11:16 AM

The next tool in the list is to keep a large enviornment in Sync. The problem is that over time arrays have been added, and different people have set them up. the autosupport settings on no two arrays are the same, and the notifications of things like drive failures are going to the wrong people. The fastest way to solve this problem was to take an array that is operating perfectly, and sending to the correct people, and to replicate those settings to each array in the farm. This script does just that. If you run the script with a Working Array, and a Target Array, it will tell you what changes need to be made on the target array to bring it into compliance. If you run Verbose Mode, it will give you all settings and highlight the differences. If you run the command with an Execute option, it will tell you the differences then fix the Target Array for you automatically.

The command can be run in the following three ways

     PowerShell Prompt > AutoSupportChecker.ps1

     PowerShell Prompt > AutoSupportChecker.ps1 "Verbose"

     PowerShell Prompt > AutoSupportChecker.ps1 "Execute"

Shown below is the default mode in which it only highlights the differences.

Sample Output of Default Mode.

PS C:\Software\toolkit> .\autosupportchecker.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
------------------------------------------------
    autosupport.enable = on
        -Values Mismatch = off
        To fix this issue, command is as follows;
           set-naoption autosupport.enable  on
    autosupport.from =
chris.lionetti@netapp.com
        -Values Mismatch = lionetti@netapp.com
        To fix this issue, command is as follows;
           set-naoption autosupport.from 
chris.lionetti@netapp.com
    autosupport.noteto = interestedparty@netapp.com
        -Values Mismatch = myboss@netapp.com
        To fix this issue, command is as follows;
           set-naoption autosupport.noteto 
interestedparty@netapp.com


PS C:\Software\toolkit>

Sample Output of the Verbose Mode

PS C:\Software\toolkit> .\autosupportchecker.ps1 "Verbose"

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.
------------------------------------------------
    autosupport.cifs.verbose = off
    autosupport.content = complete
    autosupport.doit = DONT
    autosupport.enable = on
        -Values Mismatch = off
        To fix this issue, command is as follows;
           set-naoption autosupport.enable  on
    autosupport.from =
chris.lionetti@netapp.com
        -Values Mismatch = lionetti@netapp.com
        To fix this issue, command is as follows;
           set-naoption autosupport.from 
chris.lionetti@netapp.com
    autosupport.local.nht_data.enable = off
    autosupport.local.performance_data.enable = off
    autosupport.mailhost = mailhost
    autosupport.minimal.subject.id = systemid
    autosupport.nht_data.enable = on
    autosupport.noteto =
interestedparty@netapp.com
        -Values Mismatch = myboss@netapp.com
        To fix this issue, command is as follows;
           set-naoption autosupport.noteto 
interestedparty@netapp.com
    autosupport.partner.to =
    autosupport.performance_data.doit = DONT
    autosupport.performance_data.enable = on
    autosupport.retry.count = 15
    autosupport.retry.interval = 4m
    autosupport.support.enable = on
    autosupport.support.proxy =
    autosupport.support.to =
autosupport@netapp.com
    autosupport.support.transport = https
    autosupport.support.url = support.netapp.com/asupprod/post/1.0/postAsup
    autosupport.throttle = on
    autosupport.to =
your.name@your.domain.com


PS C:\Software\toolkit>

Script Contents are Below. highlighted in RED are the settings you should change for your enviornment.

# This script will connect to a Storage Controller and retreive all
# of the AutoSupport Setttings. It will then connect to a second
# controller and compair those settings. The recommended changes will be shown.

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

$workingController = "10.58.99.254"
$targetController = "10.58.99.253"
$User = "administrator"
$Pass = "YourPasswordHere"


$WCPass  = ConvertTo-SecureString $Pass -AsPlainText –Force
$Wcred = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $User,$WCPass
$TCPass  = ConvertTo-SecureString $Pass -AsPlainText –Force
$Tcred = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $User,$WCPass
Connect-NaController $WorkingController -Credential $Wcred
$Workops = get-naoption autosupport.*
Connect-NaController $TargetController -Credential $Tcred
$Targops = get-naoption autosupport.*
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 ($item in $workops)
{    $workname=$item.name
     $workval =$item.value
     foreach($titem in $targops)
     {     if ($titem.name -eq $item.name)
           {     if ($titem.value -eq $item.value)
                {     if ($argument -eq "Verbose")
                      {     write-host "   "$item.name"="$item.value
                      }
                 }
                else
                {     write-host "   "$item.name"="$item.value
                      write-host "        -Values Mismatch ="$titem.value
                      if ($argument -eq "Execute")
                      {      write-host "        Changing Setting to match"
                            set-naoption $titem.name $item.value
                      }
                      else
                     {      write-host "        To fix this issue, command is as follows;"
                            write-host "           set-naoption"$titem.name""$item.value
                     }
                }
            }
      }
}

Comments

This script is great any ideas how we can have multiple target hosts?

New Contributor

I have added a new script at this location https://communities.netapp.com/docs/DOC-14848 where I run against as many arrays as you want. I took away the arguments such as verbose and execute in favor of exporting the output directly to excel.

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.