VMware ESXi 6.5 RDM Initialization

1 – Get Required PowerShell Modules

Install VMWare PowerCLI:

This is VMWare’s PowerCLI PowerShell module. Used to interact with vCenter.

Find-Module -Name VMware.PowerCLI
Install-Module -Name VMware.PowerCLI -Scope CurrentUser


Install Set-VMWareRDM

This is a custom module to allow us to easily configure RDM devices and other volume settings.


Copy Module Files:



Into PowerShell Global Module Folder:


Rename the files:

Set-VMWareRDM_psm1.txt –> Set-VMWareRDM.psm1

Set-VMWareRDM_psd1.txt –> Set-VMWareRDM.psd1


2 – Get RDM List from existing farm

Since the new farm can’t get the listing of RDM’s because all of the RDM’s exist only in the old farm, connected to VM’s running in the old farm; we have to get a list of RDM’s from the old farm, so that we can pre-set their perennial reservations in the new farm, and not have slow boot up times.

Once we have the CSV file, we don’t have to re-run this script.

#Connect to old VCenter:

#Import our custom module
Import-Module Set-VMWareRDM -Force

#Connect to the old vCenter server
Connect-VCenterServer -vCenter vc01.contoso.com

#Get the listing of RDM devices and export out to a CSV file
$RDM = Get-RDMDevice
$RDM | Export-Csv .\RDMList.csv

#Disconnect from the vCenter server


3 – Initialize new ESXi Host

After a fresh ESXi install, we need to run the custom commands to initialize the host. This includes creating ALUA Rules, applying storage rules, and setting perennial reservations.

#Import our custom module
Import-Module Set-VMWareRDM -Force

#Connect to the new VCenter server
Connect-VCenterServer -vCenter vc02.contoso.com

#This is our ESXi Host computer that we are going to operate on. CHANGE to the Right SERVER NAME
$ESXiHost = "ESXi01.contoso.com"

#Rescan all storage so that we have all storage available.
Get-VMHost $ESXiHost | Get-VMHostStorage -RescanAllHba

#Run through our initialization
Initialize-NewHost -ESXiHost $ESXiHost

#Set the RDM's to perennially reserved from the CSV file
$RDM = Import-Csv .\RDMList.csv
$RDM | Initialize-NewRDM -ErrorAction SilentlyContinue


4 – Verification

We want to verify that settings were set correctly

# 0. Get Power CLI object
$esxcli = Get-CLI -ESXiHostName $ESXiHost

# 1. Check for ALUA Rule
$Alua = ($esxcli.storage.nmp.satp.rule.list.Invoke() | where {$_.vendor -eq "3PARdata"})
if($Alua.count -eq 1)
Write-Host "`n`nPASS - ALUA Rule Present`n`n" -ForegroundColor Green
Write-Host "`n`nFAIL - ALUA Rule Not Present - Re-run Initialize-NewHost`n`n" -ForegroundColor Red

# 2. Check that we see more than 10 SCSI Luns - ensure that we see all the LUN's, and not just the local disk
$VMHost = Get-VMHost $ESXiHost
$AllLUNs = Get-ScsiLun -LunType disk -VmHost $VMhost
$RRLUNs = ($AllLUNs | where { $_.MultipathPolicy -eq "RoundRobin" })
$RRLUNs | ft -AutoSize

if($RRLUNs.count -gt 10)
Write-Host "`n`nPASS - More than 10 SCSI LUN's connected`n`n" -ForegroundColor Green
Write-Host "`n`nFAIL - Less than 10 SCSI LUN's connected - Re-run RescanAllHba and Initialize-NewHost`n`n" -ForegroundColor Red

# 3. Check perennial reservations for a known RDM device
$RDMdevice = $esxcli.storage.core.device.list.Invoke(@{device='naa.40000bb000000000000000b600007847'})
if($RDMdevice.IsPerenniallyReserved -eq $true)
Write-Host "`n`nPASS - Perennial Reservations set correctly`n`n" -ForegroundColor Green
Write-Host "`n`nFAIL - Perennial Reservations Not set correctly Re-run RDM CSV export and import`n`n" -ForegroundColor Red


5 – Restart

If all verification steps have completed, re-boot host to make settings permanent.

Restart-VMHost $ESXiHost -Force