PowerCLIvHerseyVMware

Set Default PSP for a SATP with PowerCLI

Another in my series of scripts to help with vSphere implementations. This script uses the PowerCLI cmdlet Get-EsxCli to execute the esxcli command to set the default PSP policy ($defaultpsp) for the specified SATP ($satp) on each host in connected vCenter inventory.

Just set the $defaultpsp to the required PSP and set $satp to the SATP that the PSP will be set on. Once the variable have been set connect to vCenter using Connect-VIServer and execute the script. The script uses Get-VMHost to retrieve the list of hosts in the connected vCenter inventory then uses Get-EsxCli to set the default PSP for the configured SATP on each host.

The script as it is configured below sets the VMW_SATP_DEFAULT_AA to the PSP VMW_PSP_RR.

# Change the Default PSP for a SATP
# PowerCLI Session must be connected to vCenter Server using Connect-VIServer

# Define the default PSP to set VMW_PSP_MRU, VMW_PSP_RR, VMW_PSP_FIXED
$defaultpsp = "VMW_PSP_RR"

# Define the SATP to Set Default PSP to $defaultpsp
# This will depend on the SATP used associated with the connected array
# For example the SATP for an EMC VNXe is VMW_SATP_DEFAULT_AA
$satp = "VMW_SATP_DEFAULT_AA"

$esxHosts = Get-VMHost

foreach ($esx in $esxHosts) {

   Write-Host "Setting Default PSP to $defaultpsp for SATP $satp on $esx" -ForegroundColor green

   $esxcli = Get-EsxCli -VMHost $esx
   $esxcli.storage.nmp.satp.set($null,$defaultpsp,$satp)

}
Write-Host "Done!" -ForegroundColor green

Saves a lot of time since you do not have to connect directly to each host either by SSH, ESXi Shell, or using esxcli remotely to configure each host.

As always comments or recommendations for improvement are always welcome.

2 thoughts on “Set Default PSP for a SATP with PowerCLI

  • Hello Hersey,
    How to get set PSP for a specific cluster?

    Reply
    • Hi vikram, you can get the list of hosts for a specific cluster in the following way:

      # Get-Cluster “clusterName” | Get-VMHost

      Reply

Leave a Reply

Your email address will not be published. Required fields are marked *

16 − ten =