First, I want to thank Glenn Sizemore for his kick ass approach of scripting and mirroring the Igroups..(See other thread)
Here's the completed script to mirror igroups, initiators and LUN Mappings..- For the purpose of testing I threw an If statement in there to grab just one igroup. You can remove the if statement if you want all igroups..
$sourcecontroller = Connect-NaController filera
$dstcontroller = Connect-NaController filerb
# Get Lun Info on Source Controller
$igroups = Get-NaIgroup -Controller $sourcecontroller
$LunInfo = Get-NaLun -Terse -Controller $sourcecontroller | where-object {$_.path -notlike "*sv*"} | Get-NaLunMap -Controller $sourcecontroller | Group-Object Name
## Loop through existing $igroup info
foreach ($Igroup in $igroups) {
if ($Igroup.name -eq "igroupname")
{
#Write-out command for testing igroup creation"
Write-Host "`nCreating Igroup:" $Igroup.name "On controller" $dstcontroller
Write-Host "--------------------------------------------------------"
New-NaIgroup -Name $Igroup.Name -Type $Igroup.type -protocol $Igroup.protocol -controller $dstcontroller -confirm:$false
## Adding initators to Igroup
Write-Host "`nAdding Initators: " $Initiators " to Igroup" $Igroup.name
$Initiators = $iGroup.Initiators | Select-Object -ExpandProperty 'InitiatorName'
$Initiators | Add-NaIgroupInitiator -igroup $igroup.name -Controller $dstcontroller -confirm:$false
Write-Host "`n"
### Add Lun Mappings for Igroup
Write-Host "`nAdding Lun Mappings for: " $Igroup.name
foreach ($lun in ($LunInfo| where {$_.Name -eq $igroup.Name} | select -ExpandProperty Group)) {
Write-Host "`t`t`tLUN:" $lun.lunID ":" $lun.path
Add-NaLunMap -Path $lun.path -InitiatorGroup $Igroup.name -ID $lun.lunid -Controller $dstcontroller -verbose
}
}
}