SHIFT

--- Sjoerd Hooft's InFormation Technology ---

User Tools

Site Tools


Sidebar

Recently Changed Pages:

View All Pages


View All Tags


LinkedIn




WIKI Disclaimer: As with most other things on the Internet, the content on this wiki is not supported. It was contributed by me and is published “as is”. It has worked for me, and might work for you.
Also note that any view or statement expressed anywhere on this site are strictly mine and not the opinions or views of my employer.


Pages with comments

View All Comments

scriptcopyinitiatorgroup

Script: Copy Initiatorgroups Between NetApp Filers

This script can be used to copy all initiators within an initiator group to another filer.

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
}
You could leave a comment if you were logged in.
scriptcopyinitiatorgroup.txt · Last modified: 2021/09/24 00:25 (external edit)