Just a few scripts I put together in preparation for a migration project which involves NetApp HCI iSCSI storage.
The same PowerShell modules work with Solidfire arrays as well.
Instructions on how to install the PowerShell modules and use them are in the following links.
https://blog.netapp.com/getting-started-with-powershell-for-netapp-hci/
Use the following script to create multiple volumes.
CSV should include a single column with header “Name” followed by volume names.
Volume name example:
BOOT-LUN-esx011
$Account = Get-SFAccount esxiboot
$QoSPolicy = Get-SFQoSPolicy -Name qos-policy-1
$Volumes = (Import-CSV C:\temp\volumes.csv).Name
foreach ($Volume in $Volumes)
{
New-SFVolume -Name $Volume -AccountID $Account.AccountID -TotalSize 7 -GB -
Enable512e:$true -QosPolicy $QoSPolicy.QoSPolicyID
}
Use the following script to create multiple iSCSI initiators.
CSV should include two columns, first column with header row “Name” followed by initiator names, second column with header row “Alias” followed by the aliases for each initiator.
Initiator name example:
iqn.2020-01.com.cisco:fabric-ab-1:11
Alias example:
esx-011
$CSV = Import-CSV C:\temp\initiators.csv
$CSV | %{
$Name = $_.Name
$Alias = $_.Alias
New-SFInitiator -Name $Name -Alias $Alias
}
Use the following script to create access groups and assign volumes and initiators to groups.
CSV should include three columns, first column with header row “Name” followed by access group names, second column with header row “Volume” followed by the volume names (previously created), and third column with header row “IQN” followed by the initiator names (previously created).
Access Group name example:
BOOT-LUN-AG-esx011
Volume name example:
BOOT-LUN-esx011
Initiator name example:
iqn.2020-01.com.cisco:fabric-ab-1:11
$CSV = Import-CSV C:\temp\access-groups.csv
$CSV | %{
$Name = $_.Name
$Volume = $_.Volume
$IQN = $_.IQN
New-SFVolumeAccessGroup -Name $Name
$AGID = Get-SFVolumeAccessGroup $Name | Select VolumeAccessGroupID
$VolumeID = Get-SFVolume $Volume | Select VolumeID
Set-SFVolumeAccessGroup -VolumeAccessGroupID $AGID.VolumeAccessGroupID -Volumes
$VolumeID.VolumeID -Initiators $IQN
}
Very useful..thanks.
Pingback: Delete multiple NetApp HCI / Solidfire volume snapshots with PowerShell - myitblog