scriptcopyinitiatorgroup
Powershell: Copy Initiatorgroups Between NetApp Filers
Summary: This script can be used to copy all initiators within an initiator group to another filer.
Date: Around 2014
Refactor: 6 April 2025: Checked links and formatting.
The Code
# Script variables $scriptname = [System.IO.Path]::GetFilenameWithoutExtension($MyInvocation.MyCommand.Path.ToString()) $scriptlocation = Split-Path $myinvocation.mycommand.path $timestamp = Get-Date -format "yyyyMMdd-HH.mm" $filercred = (Get-Credential) $srcfiler = "filer01a" $dstfiler = "filer01b" # Import DATA ONTAP Module Import-module D:\DataONTAP # Connect to the source controllers. Connect-NaController $srcfiler -credential $filercred # Get Required IGroup on the source controller. # $IGroups = Get-NaIgroup | Where {$_.Name -like "Production"} $IGroups = Get-NaIgroup # Connect to the destination controllers. Connect-NaController $dstfiler -credential $filercred # Get all the IGroups on the destination controller. $ExistingIGroups = Get-NaIgroup # Create any missing IGroups, and verify all Initiators. Foreach ($IGroup in $IGroups){ # Get the current IGroup $I = $ExistingIGroups | Where {$_.Name -eq $IGroup.Name} # Create non-existing groups if (-Not $I){ $I = New-NaIgroup -Name $IGroup.Name -Protocol $IGroup.Protocol -Type $IGroup.Type } # Add any missing initiators from the source $Initiators = $I.Initiators | Select -ExpandProperty 'InitiatorName' $IGroup.Initiators | Where {$Initiators -notContains $_.InitiatorName} |Add-NaIgroupInitiator -Igroup $I.Name }
scriptcopyinitiatorgroup.txt · Last modified: by 127.0.0.1