I'm trying to find the right syntax to do the following;
1) Connect to vCenter
2) Select all hosts in maintenance mode
3) Select each LUN configured to use MRU or Fixed
4) Configure each LUN to use RoundRobin for the path selection policy
Connect-VIServer vCenterServerName.fqdn.com
Get-VMHost|Get-ScsiLun -LunType “disk”|where {$_.State -eq “Maintenance”}|where {$_.MultipathPolicy –ne “RoundRobin”}|Set-ScsiLun -MultipathPolicy “RoundRobin”}
If someone could confirm the syntax for me that would be brilliant.
The reason I want this script is because I need something simple that I can use to update a host or several at a time, that has recently been added or re-imaged to an environment where the storage Vendor recommendation is to use RR.
Cheers,
Paul
The filtering of the VMhosts that are in maintenance mode should come sooner.
Like this
Connect-VIServer vCenterServerName.fqdn.com
Get-VMHost | where {$_.State -eq “Maintenance”} | `
Get-ScsiLun -LunType "disk" |where {$_.MultipathPolicy –ne "RoundRobin"} | `
Set-ScsiLun -MultipathPolicy "RoundRobin"Disconnect-VIServer vCenterServerName.fqdn.com
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
The filtering of the VMhosts that are in maintenance mode should come sooner.
Like this
Connect-VIServer vCenterServerName.fqdn.com
Get-VMHost | where {$_.State -eq “Maintenance”} | `
Get-ScsiLun -LunType "disk" |where {$_.MultipathPolicy –ne "RoundRobin"} | `
Set-ScsiLun -MultipathPolicy "RoundRobin"Disconnect-VIServer vCenterServerName.fqdn.com
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
I had a feeling that was the case.
It makes logical sense that I would first look for hosts that are in maintenance mode, rather then first look for disks of a certain type.
Thank you very much.
One more question if I may;
I'm worried that this script might change settings for the locally attached ESXi OS disks and/or the HBA, are my fears unfounded?
Regards,
Paul
No, no, your fear is founded.
But you can limit the LUNs by adding the HBA parameter and only report on FibreChannel HBAs
Connect-VIServer vCenterServerName.fqdn.com
Get-VMHost|where {$_.State -eq “Maintenance”} | `
Get-ScsiLun -LunType "disk" -Hba (Get-VMHostHba -Type "FibreChannel") | `
Disconnect-VIServer vCenterServerName.fqdn.com
where {$_.MultipathPolicy –ne "RoundRobin" | `
Set-ScsiLun -MultipathPolicy "RoundRobin"
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Again, my thanks. I really appreciate your input very much.
Hmmm
Would it be bad to also use RR to your local disks?
Does it matter? (i mean when theres only 1 path)
Regards
Tyler
Good point. At the very least it would be a non standard configuration.
I prefer for my implementations to stay as close to vanilla or standard as possible unless otherwise required.