Create vMotion TCP/IP stack when making vMotion VMKernel interface with PowerCli

This series of commands will set the default gateway on the vMotion kernel to use dedicated Default Gateway for layer 3 vMotion.

After you connect to the target VCSA (vCenter) update the variables



# Update the Variables Below
$esxi = "ESXi hostname"
$vdsswitchname = "DVS Switch Name"
$vmotionportgroup = "Portgroup to use for VMotion"
$vmotionIP = "IP address of the Vmotion Kernel"
$vmotiongateway = "The Vmotion Default Gatway"
$VmotionSubnetMask = "VMotion Subnet Mask"
# End of Variables

$vds = Get-VDSwitch $vdsswitchname
$hostobject = get-vmhost $esxi
$vmostack = Get-VMHostNetworkStack -vmhost $hostobject | ? {$_.ID -eq "vmotion"}
New-VMHostNetworkAdapter -VirtualSwitch $vds -VMHost $hostobject -PortGroup  -ip $vmotionIP -SubnetMask $VmotionSubnetMask -NetworkStack $vmostack -Confirm:$false
$vmostackconfig = New-Object VMware.Vim.HostNetworkConfig
$vmostackconfig.NetStackSpec = New-Object VMware.Vim.HostNetworkConfigNetStackSpec[] (1)
$vmostackconfig.NetStackSpec[0] = New-Object VMware.Vim.HostNetworkConfigNetStackSpec
$vmostackconfig.NetStackSpec[0].NetStackInstance = New-Object VMware.Vim.HostNetStackInstance
$vmostackconfig.NetStackSpec[0].NetStackInstance.RequestedMaxNumberOfConnections = 11000
$vmostackconfig.NetStackSpec[0].NetStackInstance.CongestionControlAlgorithm = 'newreno'
$vmostackconfig.NetStackSpec[0].NetStackInstance.IpRouteConfig = New-Object VMware.Vim.HostIpRouteConfig
$vmostackconfig.NetStackSpec[0].NetStackInstance.IpRouteConfig.DefaultGateway = $vmotiongateway
$vmostackconfig.NetStackSpec[0].NetStackInstance.Key = 'vmotion'
$vmostackconfig.NetStackSpec[0].Operation = 'edit'
$changmode = 'modify'
$_this = Get-View -Id $hostobject.NetworkInfo.Id
$_this.UpdateNetworkConfig($vmostackconfig, $changmode)