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
$excel.Visible=$true
$workbooks=$excel.workbooks.add()
$worksheet=$workbooks.worksheets.item(1)
$worksheet.cells.item(1,1)="Option Name"
$worksheet.cells.item(1,1).font.bold=$true
$worksheet.cells.item(1,1).font.size=22
$worksheet.cells.item(2,1)="Controller Name"
$worksheet.cells.item(2,1).font.bold=$true
$worksheet.cells.item(2,1).font.size=22
$worksheet.cells.item(1,2)="Master FAS"
$worksheet.cells.item(1,2).font.bold=$true
$worksheet.cells.item(1,2).font.size=22
$worksheet.cells.item(2,2)=$WorkingController
$cellR=3
foreach($Controller in $TargetControllers)
{ Connect-NaController $Controller
$Workops.add( (get-naoption ) )
$worksheet.cells.item(1,$cellr)="Target FAS"
$worksheet.cells.item(1,$cellr).font.bold=$true
$worksheet.cells.item(1,$cellr).font.size=22
$worksheet.cells.item(2,$cellr++)=$controller
}
$worksheet.cells.item(1,$cellr)="Command to fix"
Write-host "------------------------------------------------"
$coun=2
foreach ($workop in $workops)
{ $coun=$coun+1
$line=2
$founditem=$false
foreach ($item in $workop)
{ $workname=$item.name
$workval =$item.value
foreach($titem in $targops)
{ if ($titem.name -eq $item.name)
{ $line=$line+1
$foundvalue=$true
$worksheet.cells.item($line,1)=$titem.name
$worksheet.cells.item($line,2)=$titem.value
$worksheet.cells.item($line,$coun)=$item.value
write-host " "$item.name"="$item.value
if ($titem.value -ne $item.value)
{ write-host " "$item.name"="$item.value" -Values Mismatch ="$titem.value
$worksheet.cells.item($line,$cellr)=("set-naoption"+$titem.name+" "+$item.value)
write-host " To fix this issue, command is as follows;"
write-host " set-naoption"$titem.name""$item.value
}
}
}
}
}
$workdoc=$worksheet.UsedRange
$workdoc.EntireColumn.Autofit() | out-null