Configure virtual machine for nested ESX/ESXi with PowerCLI

I’ve been working with several scripts in a lab recently. Most of these labs require additional ESXi hosts (namely vCheck testing) so I’ve been propping up some nested ESXi virtual machines. When I create a virtual machine to run nested ESXi, I typically set three advanced configuration options:

monitor_control.restrict_backdoor = TRUE
monitor_control.vt32 = TRUE
SMBIOS.reflectHost = TRUE
  • The first option listed allows you to run virtual machines inside your nested ESXi installations.
  • The VT32 option is specifically geared for Intel hardware; if you are using AMD hardware you’ll probably want to use monitor_control.enable_svm = TRUE instead.
  • The final option is not really required; it simply makes the nested ESXi host look more like a physical server. If you do this on an HP server, the virtual ESXi host appears as an HP instead of being a VMware, Inc. Virtual Machine Platform.

While three copy/paste operations into the advanced settings window isn’t challenging or time consuming, I thought it would be better if this could be done with PowerCLI.

[cc lang=”powershell”]
#Monitor Control/Restrict Backdoor
$extrarbd = New-Object VMware.Vim.optionvalue
$extrarbd.Key=”monitor_control.restrict_backdoor”
$extrarbd.Value=”TRUE”

#Monitor Control/VT32
$extravt32 = New-Object VMware.Vim.optionvalue
$extravt32.Key=”monitor_control.vt32″
$extravt32.Value=”TRUE”

#SMBIOS/Reflect Host
$extraref = New-Object VMware.Vim.optionvalue
$extraref.Key=”SMBIOS.reflectHost”
$extraref.Value=”TRUE”

#Create a Machine Config Spec using the three option values specified above
$vmConfigSpec = New-Object VMware.Vim.VirtualMachineConfigSpec
$vmConfigSpec.extraconfig += $extrarbd
$vmConfigSpec.extraconfig += $extravt32
$vmConfigSpec.extraconfig += $extraref

#Get a VM View collection of all the VMs that need to have these options
$vms = get-view -viewtype virtualmachine |where {$_.name -eq “mytestesxi01”}
foreach($vm in $vms){
$vm.ReconfigVM($vmConfigSpec)
}
[/cc]

I’ve used this on two virtual machines and it appears to work okay. Please feel free to drop a comment if you have any questions.

This entry was posted in Scripting, Virtualization. Bookmark the permalink.

One Response to Configure virtual machine for nested ESX/ESXi with PowerCLI

  1. Upul says:

    hi,

    what a amazing three lines. I was struggling with nesting esxi & you saved me a lot.
    Good work.

Leave a Reply

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

*

Notify me of followup comments via e-mail. You can also subscribe without commenting.