PowersHell: Enabling “Management Traffic” on VMKernel port for ESXi

Describes the steps you must follow in order to enable "Management Traffic" on VMKernel port for ESXi.

Well, this particular configuration has been outstanding for me for more than a month and I’ve finally cracked it. Borrowing from Carter Shaklin’s example of enabling FT Logging, I found a method of doing this:

You have to be a little bit careful when you run this script. You don’t need this script with ESX “Classic”, which uses the Service Console. For that, you can use the -consoleNIC parameter to make sure the new VMHostNetworkAdapter is a vswif interface rather than a vmkernel interface.

$vs3 = vSwitch3
$HAheartbeat = New-VirtualPortGroup -VirtualSwitch $vs3 -Name HA-Heartbeat
New-VMHostNetworkAdapter -PortGroup HA-Heartbeat -VirtualSwitch $vs3 -IP $HAheartbeatIP -SubnetMask -ConsoleNic

To do the same for ESXi, you have to dig into the SDK by using the data object virtualNicManager held with configManager to set the “Management Traffic” attribute.

$hView = Get-VMHost esx4.vi4book.com | Get-View -Property configManager
$nicManager = Get-View $hView.configManager.virtualNicManager
$nicManager.SelectVnicForNicType("management", "vmk2")

The only slightly annoying thing about this PowersHell is that I don’t think I would have found these parameters without the help of the PowerCLI product manager. I’m trying to work out how he found these values; it could wind-up being an internal engineering thing, rather than something in the public domain. Well, it is public now :-)

I suspect that the SelectVnicForNicType companion QueryNetConfig was used to find out the variables on an existing configured ESXi host to find out the values for ”faultToleranceLogging” and “management”. I wasn’t so clever, I worked out “management” by guessing! 


Anyways, after posting this the Product Manager for the PowerCLI ping’d me an email with a URL showing where the values of “management”, “vmotion” and “faultToleranceLogging” were held on.


Dig Deeper on Scripting administrative tasks