function Set-VMHostMultipathPolicy { param ( [string]$LunId, [string]$PolicyName ) Begin { function ShowUsage { Write-Host @" NAME Set-VMHostMultipathPolicy SYNOPSIS Changes the multi-path policy of specified LUNs. SYNTAX Get-VMHost | Set-VMHostMultipathPolicy [-LunId] [-PolicyName] DETAILED DESCRIPTION Input is provided to this function by passing VMHostImpl objects to it on the pipeline. Both the LunId and PolicyName parameters are required. PolicyName can be one of three values: fixed, mru, or rr. "@ } if ( !$LunId ) { ShowUsage Throw "LunId is a required parameter" } $ValidPolicies = 'fixed', 'mru', 'rr' if ( $ValidPolicies -notcontains $PolicyName ) { ShowUsage Throw "ValidPolicies must be one of the following: fixed, mru, rr" } } Process { if ( $_ -isnot [VMware.VimAutomation.Client20.VMHostImpl] ) { continue } $HostStorageSystem = Get-View ( $_ | Get-View ).ConfigManager.StorageSystem $HostMPPolicy = New-Object Vmware.Vim.HostMultipathInfoLogicalUnitPolicy $HostMPPolicy.policy = $PolicyName $HostStorageSystem.SetMultiPathLunPolicy( $LunId, $HostMPPolicy ) } }