VMware Cloud Community
thiag2011
Enthusiast
Enthusiast

Script to get path policy of all datastores

Dear all,

I require a script which checks the path policy of all datastores in a vcenter.

Also it needs to change the path policy to round robin, if it is not set to round robin already.

I have written a script for the same. But this requires manual feeding of esxi hosts names and also the script is very slow.

Please help.

MYSCRIPT:

ForEach ($Server in Get-Content ("Servers.txt") )

{

Get-VMHost $Server | Get-ScsiLun -LunType "disk" |where {$_.MultipathPolicy -ne "RoundRobin"}|Set-ScsiLun -MultipathPolicy RoundRobin

Write-output  “Completed on” $Server >> outputresolved.csv

}

2 Replies
LucD
Leadership
Leadership

Can't you just do this

Get-VMHost | Get-ScsiLun -LunType "disk" |where {$_.MultipathPolicy -ne "RoundRobin"}| Set-ScsiLun -MultipathPolicy RoundRobin


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

thiag2011
Enthusiast
Enthusiast

Hi Luc,

Yes, but this process is slow, when I have lot of datastores.

Is there a way, instead of piping it via vmhost, can i directly check the datastore ( something via get-datastore ) which may be faster.

Am not able to find any.

Reply
0 Kudos