- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
}
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Forgot to add Glenn's check for ALUA.. That's all i'm concerned with.. Throw this in the for loop
## ADD alua check
| if ($Igroup.InitiatorGroupAluaEnabled -eq $true) | |
| { | |
| Write-Host "Adding ALUA to Igroup:" $Igroup.name | |
| Set-NaIgroup -Name $Igroup.name -Key alua -Value $IGroup.InitiatorGroupAluaEnabled -Controller $dstcontroller -Force | |
| } |
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I know some of you out there use aliases, upon checking I figured I would add it..
Add this do the code
$existingaliases = Get-NaFcpPortNameAlias -Controller $sourcecontroller
## Set Aliases via looping through it
If ($existingaliases -ne $null) {
foreach ($alias in $existingaliases) {
Set-NaFcpPortNameAlias -PortName $alias.aliaseswwpn -Alias $alias.aliasesalias -Controller $dstcontroller -Force -Verbose
}
}
Enjoy!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Very cool i'm glad my script helped kick start your project.
Thanks for sharing the Code!!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks. You and clinton always get me moving in the correct direction.
And i'm all about sharing.. that's how everyone learns and is able to use the awesome powershell snapins..