VMware Cloud Community
ganapa2000
Hot Shot
Hot Shot

Is there a way to shorten this script

Hi,

Is there a way to shorten this script

Get-Cluster "ClusterA" | Get-VMHost -PipelineVariable esx |
where {($_.ConnectionState -like "Connected")} | ForEach-Object -Process {
$esxcli = Get-EsxCli -VMHost $esx -V2
#Remove Exisiting Rule
$Nimble = @{
satp = 'VMW_SATP_ALUA'
psp = 'VMW_PSP_RR'
vendor = 'Nimble'
}
$esxcli.storage.nmp.satp.rule.remove.Invoke($Nimble)
#Add SATP Nimble Rule
$Nimble1 = @{
pspoption = 'policy=iops;iops=1'
satp = 'VMW_SATP_ALUA'
psp = 'VMW_PSP_RR'
vendor = 'Nimble'
}
$esxcli.storage.nmp.satp.rule.add.Invoke($Nimble1)
#Set Round Robin Multipathing for exisiting devices
$esxcli.storage.nmp.device.list.Invoke() | where { $_.Device -match "^eui\.\w{16}(6c9ce9|6C9CE9)\w{10}"} |
ForEach-Object -Process {
$sSet = @{
device = $_.device
psp = 'VMW_PSP_RR'
}
$esxcli.storage.nmp.device.set.CreateArgs()
}
#Set IOPS to 1 for exisiting devices
$esxcli.storage.nmp.device.list.Invoke() | where { $_.Device -match "^eui\.\w{16}(6c9ce9|6C9CE9)\w{10}"} |
ForEach-Object -Process {
$sSet = @{
device = $_.device
type = 'iops'
iops = 1
}
$esxcli.storage.nmp.psp.roundrobin.deviceconfig.set.Invoke($sSet)
}
}

0 Kudos
1 Reply
LucD
Leadership
Leadership

Besides moving the creation of the has tables outside the loop, and only changing a specific property inside the loop, not a lot to shorten I think.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos