VMware: Set MAC Address of a kernel interface with PowerCli

Hi,

the New-VMHostNetworkAdapter offers the ability to set the MAC address while adding a new kernel interface. But this has a limitation. It always only a MAC within a range 00:50:56:00:00:00 – 00:50:56:3F:FF:FF.

If you try it even though you will get an error:

New-VMHostNetworkAdapter The MAC address is invalid or is not in the valid range 00:50:56:00:00:00 - 00:50:56:3F:FF:FF.


But its possible. Use the following code

# Get Host
$sESXIHost="myesxihost01.mydomain.org"
$sNICToChange="vmk1"
$sMAC="00:50:56:ef:20:eb"
$sIPAddress="10.10.20.1"
$sSubnetMask="255.255.255.0"
$oESXiHost=Get-VMHost $sESXIHost
$oHostIpConfig=new-object VMware.Vim.HostIpConfig
$oHostIpConfig.IpAddress=$sIPAddress
$oHostIpConfig.SubnetMask=$sSubnetMask
$oHostIpConfig.IpV6Config=$null
$oHostIpConfig.Dhcp=$false
$oHostNicSpec=new-object VMware.Vim.HostVirtualNicSpec
$oHostNicSpec.Ip=$oHostIpConfig
$oHostNicSpec.Mac=$sMAC
$oHostNetworkSystem=get-view -id $oESXiHost.ExtensionData.ConfigManager.Networksystem
$oHostNetworkSystem.UpdateVirtualNic($sNICToChange,$oHostNicSpec)		

Michael

Advertisment to support michlstechblog.info

Time limit is exhausted. Please reload CAPTCHA.

Original Theme by Schiy · Powered by WordPress