For the uninitiated, there are two basic kinds of scripting arenas available for VMware admins: the vSphere CLI, based on the traditional Windows batch file implementation, and vSphere PowerCLI, based on PowerShell. Both have lots of functions.
vSphere CLI
The following example is my vCLI-SetRoundRobin script (downloads as a ZIP file). I have shrunk the font for format on the page. This script will go through and not only set defaults for all the various Storage Array Type Plugins (SATPs) to the Path Selection Policy (PSP) Round Robin, but will also reassign existing LUNs by rerunning the ESX storage claimrule load function (ESXi 4.1). Otherwise you can reboot your host afterward.
@echo Off echo Beginning ESX Round Robin Setup...
echo Enter the ESX server IP address...
set /p server=
echo Enter the ESX server username...
set /p username=
echo Enter the ESX server password...
set /p password=
echo Enter the ESX server fiber channel adapter #1 (e.g., vmhba3)...
set /p vmhba1=
echo Enter the ESX server fiber channel adapter #2 (e.g., vmhba4)...
set /p vmhba2=
cd "\Program Files (x86)\VMware\VMware vSphere CLI\bin"
echo.
echo Beginning Round Robin defaults setup...
esxcli --server %server% --username %username% --password %password% nmp satp setdefaultpsp --satp="VMW_SATP_DEFAULT_AA" --psp="VMW_PSP_RR"
esxcli --server %server% --username %username% --password %password% nmp satp setdefaultpsp --satp="VMW_SATP_DEFAULT_ALUA" --psp="VMW_PSP_RR"
esxcli --server %server% --username %username% --password %password% nmp satp setdefaultpsp --satp="VMW_SATP_DEFAULT_CX" --psp="VMW_PSP_RR"
esxcli --server %server% --username %username% --password %password% nmp satp setdefaultpsp --satp="VMW_SATP_DEFAULT_ALUA_CX" --psp="VMW_PSP_RR"
esxcli --server %server% --username %username% --password %password% nmp satp setdefaultpsp --satp="VMW_SATP_DEFAULT_SVC" --psp="VMW_PSP_RR"
esxcli --server %server% --username %username% --password %password% nmp satp setdefaultpsp --satp="VMW_SATP_DEFAULT_INV" --psp="VMW_PSP_RR"
esxcli --server %server% --username %username% --password %password% nmp satp setdefaultpsp --satp="VMW_SATP_DEFAULT_SYMM" --psp="VMW_PSP_RR"
esxcli --server %server% --username %username% --password %password% nmp satp setdefaultpsp --satp="VMW_SATP_DEFAULT_EVA" --psp="VMW_PSP_RR"
esxcli --server %server% --username %username% --password %password% nmp satp setdefaultpsp --satp="VMW_SATP_DEFAULT_EVA" --psp="VMW_PSP_RR"
esxcli --server %server% --username %username% --password %password% nmp satp setdefaultpsp --satp="VMW_SATP_DEFAULT_ALUA_CX" --psp="VMW_PSP_RR"
esxcli --server %server% --username %username% --password %password% nmp satp setdefaultpsp --satp="VMW_SATP_CX" --psp="VMW_PSP_RR"
esxcli --server %server% --username %username% --password %password% nmp satp setdefaultpsp --satp="VMW_SATP_ALUA_CX" --psp="VMW_PSP_RR"
esxcli --server %server% --username %username% --password %password% nmp satp setdefaultpsp --satp="VMW_SATP_EQL" --psp="VMW_PSP_RR"
esxcli --server %server% --username %username% --password %password% nmp satp setdefaultpsp --satp="VMW_SATP_INV" --psp="VMW_PSP_RR"
esxcli --server %server% --username %username% --password %password% nmp satp setdefaultpsp --satp="VMW_SATP_EVA" --psp="VMW_PSP_RR"
esxcli --server %server% --username %username% --password %password% nmp satp setdefaultpsp --satp="VMW_SATP_ALUA" --psp="VMW_PSP_RR"
esxcli --server %server% --username %username% --password %password% nmp satp setdefaultpsp --satp="VMW_SATP_SYMM" --psp="VMW_PSP_RR"
echo.
echo Round Robin defaults set.
echo.
echo Modifying existing path claim rules...
echo.
esxcli --server %server% --username %username% --password %password% corestorage claimrule load
esxcli --server %server% --username %username% --password %password% corestorage claimrule run
vicfg-rescan.pl --server %server% --username %username% --password %password% %vmhba1%
vicfg-rescan.pl --server %server% --username %username% --password %password% %vmhba2%
pause
vSphere PowerCLI
Here is my vHostListIPs script that will go out and query the currently connected VI-Host (vCenter or single ESXi host) and list the IPs on the first vNIC of the VMX configuration file. Useful for updating Excel worksheets and such, and checking for misconfigurations when doing large deployments.
A great resource is the vSphere PowerCLI Sample Scripts Library; it contains a lot of items that you can use to get started right away.