VMware Cloud Community
logiboy123
Expert
Expert
Jump to solution

Modify Path Policy PowerCLI syntax

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

Reply
0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

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

View solution in original post

Reply
0 Kudos
6 Replies
LucD
Leadership
Leadership
Jump to solution

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

Reply
0 Kudos
logiboy123
Expert
Expert
Jump to solution

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

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

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") | `
    where {$_.MultipathPolicy –ne "RoundRobin" | `
    Set-ScsiLun -MultipathPolicy "RoundRobin"

Disconnect-VIServer vCenterServerName.fqdn.com


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

logiboy123
Expert
Expert
Jump to solution

Again, my thanks. I really appreciate your input very much.

Reply
0 Kudos
TylerDurden77
Enthusiast
Enthusiast
Jump to solution

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 

Reply
0 Kudos
logiboy123
Expert
Expert
Jump to solution

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.

Reply
0 Kudos