Skip to content

Commit

Permalink
Adding function to change multipath policy
Browse files Browse the repository at this point in the history
  • Loading branch information
Malika133 committed Sep 3, 2023
1 parent a4a1454 commit 7907b0d
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
1 change: 1 addition & 0 deletions Microsoft.AVS.Management/Microsoft.AVS.Management.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
34 changes: 34 additions & 0 deletions Microsoft.AVS.Management/Microsoft.AVS.Management.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -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)"
}
}

0 comments on commit 7907b0d

Please sign in to comment.