Expert
Expert

Modify Path Policy PowerCLI syntax

Jump to solution

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

0 Kudos
1 Solution

Accepted Solutions
Leadership
Leadership

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

0 Kudos
6 Replies
Leadership
Leadership

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

0 Kudos
Expert
Expert

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

0 Kudos
Leadership
Leadership

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

Expert
Expert

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

0 Kudos
Enthusiast
Enthusiast

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 

0 Kudos
Expert
Expert

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.

0 Kudos