Microsoft Virtualization Discussions

Netapp Options Check Powershell


Hi All

Posting for some help again, I have a modified script that checks all the options of a master filer and checks target filers and show the differences, but Im struggling to get the excel to align properly for each of the options, does anyone know how to fix the formatting or is there an easier way to check a set of netapp filers against master filer through a script in perl or any other language any ideas welcome. The script is below and kinda works but half way down the options seem to get mixed up and misallgned not sure what Im doing wrong to be honest.

Ive tested it with mixed filer models and also with models that are all the same but it still doesnt work.

I just need to keep all the filers options the same like our master filer.

Any ideas I would be greatful

import-module DataONTAP

$workingController = "master_server"
$targetControllers= @("server1","server2")
$User = "xxx"
$Pass = "xxx"

$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
$workops=new-object system.collections.arraylist
ForEach ($Controller in $TargetControllers){Connect-NaController $Controller}

$suppress = $Targops = get-naoption
Write-host "------------------------------------------------"

$excel=new-object -comobject excel.application

$worksheet.cells.item(1,1)="Option Name"
$worksheet.cells.item(2,1)="Controller Name"
$worksheet.cells.item(1,2)="Master FAS"
foreach($Controller in $TargetControllers)

{          Connect-NaController $Controller
          $Workops.add( (get-naoption  ) )
           $worksheet.cells.item(1,$cellr)="Target FAS"
$worksheet.cells.item(1,$cellr)="Command to fix"

Write-host "------------------------------------------------"
foreach ($workop in $workops)
{     $coun=$coun+1
      foreach ($item in $workop)
      {      $workname=$
            $workval =$item.value
            foreach($titem in $targops)
            {     if ($ -eq $
                  {      $line=$line+1
                        write-host "   "$"="$item.value    
                        if ($titem.value -ne $item.value)
                        {      write-host "   "$"="$item.value" -Values Mismatch ="$titem.value
                              $worksheet.cells.item($line,$cellr)=("set-naoption"+$" "+$item.value)
                              write-host "        To fix this issue, command is as follows;"
                              write-host "           set-naoption"$""$item.value
$workdoc.EntireColumn.Autofit() | out-null



You might consider trying to isolate the part of the script that you are having the problem with.  I'm not very familiar with excel, and that is a lot of code with confusing variable names (item, $item, $titem) to try to visually debug.

At the very least you could indicate what type of problem you are seeing or what the output is.

Help us help you!



For example if you look at row 25 and 26 the 1440 value should be in row 26, the excel output (attached) seems to go out of sync later on in script output, rows 1-15 are fine and 19-29 have gone out of synch.

Any help would be appreciated. Its like the excel comes out of synch, you can run the script against a set of filers and see what I mean



I think you're problem is that you have different sets of options on your controllers.  I'd use the "Get-NaOption -Hashtable" switch so you can simply lookup the option you need (whether it exists or not).  Here's a really quick example to demonstrate the concept:

$masterController = Connect-NaController

$targetController = Connect-NaController

$masterOptions = Get-NaOption -Hashtable -Controller $masterController

$targetOptions = Get-NaOption -Hashtable -Controller $targetController

$allKeys = $masterOptions.Keys + $targetOptions.Keys | sort | Get-Unique

foreach ($key in $allKeys)


    Write-Host $key, $masterOptions[$key], $targetOptions[$key]


Hope that helps!


Here is a quick and dirty way of comparing the options:

$controller1= "yourfiler1"

$controller2= "yourfiler2"

Connect-NaController $controller1

$optiona= get-naoption

Connect-NaController $controller2

$optionb= get-naoption

Compare-Object $optiona $optionb


Thanks for all these ideas, ive tried the script where all the filers are the same so it ruled out there being different options/releases/models (they are the same to P release) ill still try a hashtable but think its the excel, the script actually detects if the targets differ from the master its just the excel is misalligned half way down the output. I would like to have it in an excel or text file so we can quickly see the differences for a number of filers and then I send it out to the admins via email. It was originally adopted from this script which only compared the autosupport options

I liked the way the output was so I changed this script to run for all options, not sure if I need to make another adjustment to accomodate the script for all options I changed


$suppress = $Targops = get-naoption autosupport.*

to this $suppress = $Targops = get-naoption

So it would capture all of the options not just the autosupport options but not sure if something else needs changing Ive gone through it lots of times but cant see it.

It seems to work well if you only have the autosupport* in the script