![](/style/images/good.png)
![](/style/images/bad.png)
How to script Datastore Multipathing change using PowerShell
source link: https://myvirtualcloud.net/how-to-script-datastore-multipathing-change-using-powershell/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
How to script Datastore Multipathing change using PowerShell
-
10/21/2010
There is a recurring situation that I face whenever I am deploying a new VMware View environment (also applicable to any vSphere deployment) . Due to natural limitations on number of IOPS per datastore (LUN), VMware recommends that you size your datastores for a maximum of 64 virtual desktops. This number could be higher, however you will need to pay attention to the number of IOPS required to support the workload, and verify that each LUN and backend array/spindles are able to provide the required performance. Normally this performance is measured by the latency number between I/O requests. There are references that mention that if I/O latency is higher than 10 milliseconds on average and higher than 20 milliseconds at peak your workload is under I/O contention.
Because of the limitation on number of VMs per datastore you will end up with a large number of datastores. As an example, 1000 VMs would require approximately 16 datastores. Those 16 datastores would be then presented to all hosts in a 8 node cluster. (8 hosts is the maximum host limit when using View Composer).
Now take your storage array. If the storage array supports active/active multipathing you will probably want to change the multipathing policy option to Round Robin for better throughput and utilisation of the fabric. That’s when my configuration issues begin.
To change multipathing manually trough vCenter it’s is necessary modify every datastore for each host, and after a portion of mouse clicks change the multipathing from MRU (Most Recently Used) to Round Robin. Do the math: 16 datastores x 8 hosts = 128 datastores to change multipathing. Yeah, I know it’s a pain.
Now, there are multiple PowerShell and Perl scripts widely available on the net to do a bunch of things but I haven’t found a ready-made script to automatically change multipathing for all datastores in all hosts. So, I created one to help me during my deployments.
I have to warn you that I am no PowerShell scripting expert and I know the script could be a lot more intelligent, but it works for me. So, if you want to improve the script please send it back to me for publishing with acknowledgements, off course.
Connect-VIServer vCenterServer
foreach ($hostx in get-vmhost) {
$hostview = Get-View $hostx
$storageSystem = Get-View $hostview.ConfigManager.StorageSystem
$policy = new-object VMware.Vim.HostMultipathInfoLogicalUnitPolicy#$policy.policy = "VMW_PSP_MRU"
$policy.policy = "VMW_PSP_RR"$storageSystem.StorageDeviceInfo.MultipathInfo.lun | foreach { $storageSystem.SetMultipathLunPolicy($_.ID, $policy) }
}
Note: I offer no guarantee and the script and you may use under your own responsibility.
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK