• Home
  • Virtualization
    • Citrix
    • VMware
  • Coding
    • Apache
    • Powershell
    • VBScript
  • Applications
    • Windows
      • DHCP
      • Group Policy
      • MDT
  • Mobile
    • Android
    • iOS

the STONYWALL blog

where my mind comes to rest...

Menu
  • Home
  • Virtualization
    • Citrix
    • VMware
  • Coding
    • Apache
    • Powershell
    • VBScript
  • Applications
    • Windows
      • DHCP
      • Group Policy
      • MDT
  • Mobile
    • Android
    • iOS
 › Powershell › VMware › VMware ESXi 6.5 RDM Initialization

VMware ESXi 6.5 RDM Initialization

Derek Bannard June 23, 2017     Comment Closed    

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:

Set-VMWareRDM_psm1

Set-VMWareRDM_psd1

Into PowerShell Global Module Folder:

C:\Windows\System32\WindowsPowerShell\v1.0\Modules\Set-VMWareRDM\

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
Disconnect-VCenterServer

 

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"})
$Alua
if($Alua.count -eq 1)
{
Write-Host "`n`nPASS - ALUA Rule Present`n`n" -ForegroundColor Green
}else
{
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
}else
{
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'})
$RDMdevice
if($RDMdevice.IsPerenniallyReserved -eq $true)
{
Write-Host "`n`nPASS - Perennial Reservations set correctly`n`n" -ForegroundColor Green
}else
{
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

 

Powershell VMware

 Previous Post

WMI Filtering Based on Computer Type (Desktop / Laptop)

― May 1, 2017

Next Post 

Adding DHCP server support for PXE BIOS and UEFI Booting

― July 4, 2017

Author: Derek Bannard

Related Articles

Derek Bannard ― February 1, 2019 | Comment Closed

Clear Windows Event-Logs

This powershell script… well, function. Will enumerate all Windows even-logs and clear them. This is useful when you want to

Derek Bannard ― October 24, 2018 | Comment Closed

Quick Tips: Citrix Studio Application Folder Rename

Derek Bannard ― August 31, 2018 | Comment Closed

PowerShell: Copy and Move Files Using Robocopy and CSV

Derek Bannard ― August 31, 2018 | Comment Closed

Quick Tips: MDT Task Sequence – Hide From OS or WinPE

Derek Bannard ― August 30, 2018 | Comment Closed

MDT 2013: Moving Computers Into Correct OU on AD Join

Derek Bannard ― May 22, 2018 | Comment Closed

MDT 2013: Creating a New Template

Derek Bannard ― April 3, 2018 | Comment Closed

Quick Tips: Updating ESXi Host (Online Method)

Derek Bannard ― February 3, 2018 | Comment Closed

MDT Task Sequence: Inline Surface Pro Pen Pairing without Image Modifications

Search

Categories

Recent Posts

  • Clear Windows Event-Logs
  • Quick Tips: Citrix Studio Application Folder Rename
  • PowerShell: Copy and Move Files Using Robocopy and CSV
  • Quick Tips: MDT Task Sequence – Hide From OS or WinPE
  • MDT 2013: Moving Computers Into Correct OU on AD Join

Archives

  • February 2019
  • October 2018
  • August 2018
  • May 2018
  • April 2018
  • February 2018
  • January 2018
  • July 2017
  • June 2017
  • May 2017
  • April 2017
  • November 2016

Meta

  • Log in
  • Entries RSS
  • Comments RSS
  • WordPress.org