Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding function to change multipath policy #207

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
1 change: 1 addition & 0 deletions Microsoft.AVS.Management/Microsoft.AVS.Management.psd1
Original file line number Diff line number Diff line change
@@ -100,6 +100,7 @@
"Remove-AVSStoragePolicy"
"Set-CustomDRS"
"Set-AVSVSANClusterUNMAPTRIM"
"Set-DatastoreMultipathingPolicy"
)

# Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export.
34 changes: 34 additions & 0 deletions Microsoft.AVS.Management/Microsoft.AVS.Management.psm1
Original file line number Diff line number Diff line change
@@ -2778,3 +2778,37 @@ Function Set-AVSVSANClusterUNMAPTRIM {
}
}
}

<#
.DESCRIPTION
Set default Multipath Policy to Round Robin.

.PARAMETER DatastoreName
Datastore name

.EXAMPLE
Set-DatastoreMultipathingPolicy -DatastoreName "myDatastore"

.INPUTS
vCenter datastore name.

.OUTPUTS
None.
#>
function Set-DatastoreMultipathingPolicy {
[CmdletBinding()]
[AVSAttribute(10, UpdatesSDDC = $false, AutomationOnly = $true)]
param(
[Parameter(Mandatory=$true)]
[string]$DatastoreName
)
try {
$datastore = Get-Datastore -Name $DatastoreName -ErrorAction Stop
$policy = Get-ScsiLun -Datastore $datastore | Get-View | Select-Object -First 1 -ExpandProperty MultipathPolicy
$policy.ChangePolicy("VMW_PSP_RR")
Write-Host "Successfully set Multipath Policy to Round Robin for datastore $DatastoreName."
}
catch {
Write-Error "Failed to set Multipath Policy for datastore $DatastoreName. Error: $($_.Exception.Message)"
}
}