Hello!
I have deployed a vCenter 6.7U3 with 3 ESXi hosts (6.7U3 as well) pertaining a host cluster. In addition, I have deployed and configured an NSX-T installation (latest version 2.5) and automatically migrated management vmkernel interface to a N-VDS (NSX distributed switch) portgroup during NSX-T installation.
Every ESXi host in the cluster only has 2x10G physical NICs that have been migrated to NSX Distributed Switch (not regular VDS). The question is that I want to create additional vmkernel interfaces (for example for vMotion or vSAN) in an automated way using PowerCLI, but any of the ways I've tried works.
Just for you to know, it actually can be done through the UI (HTML5 client) but neither from PowerCLI nor esxcli.
What I have tried:
OPTION 1) Use New-VMHostNetworkAdapter cmdlet:
New-VMHostNetworkAdapter -VMHost (Get-VMHost -Name "myhost.vmwaretest.com") -IP "10.10.10.25" -SubnetMask "255.255.255.0" -PortGroup (Get-VirtualNetwork -NetworkType "Opaque" -Name "test-segment1") -Confirm:$false
New-VMHostNetworkAdapter : 18/12/2019 15:33:24 New-VMHostNetworkAdapter Value cannot be found for the mandatory parameter VirtualSwitch
At line:1 char:1
+ New-VMHostNetworkAdapter -VMHost (Get-VMHost -Name "myhost.vmwarete ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [New-VMHostNetworkAdapter], VimException
+ FullyQualifiedErrorId : Core_BaseCmdlet_UnknownError,VMware.VimAutomation.ViCore.Cmdlets.Commands.Host.NewVMHostNetworkAdapter
So it seems there is no support for Opaque Virtual Portgroups and vmkernel adapters?? But for VM networking it does work:
Get-VirtualNetwork -NetworkType "Opaque"
Name NetworkType
---- -----------
test-segment1 Opaque
OPTION 2) Use Get-Esxcli cmdlet
$esxcli = Get-EsxCli -VMhost "myhost.vmwaretest.com" -V2
$vmkArgs = $esxcli.network.ip.interface.add.CreateArgs()
$vmkArgs.set_Item("interfacename","vmk1")
$vmkArgs.set_Item("portgroupname","test-segment1")
$vmkArgs.set_Item("mtu","1500")
$esxcli.network.ip.interface.add.Invoke($vmkArgs)
Message: EsxCLI.CLIFault.summary;
InnerText: Invalid vswitch port group name test-segment1. Error was: Unable to get node: Sysinfo error: Not foundSee VMkernel log for details.EsxCLI.CLIFault.summary
At line:37 char:1
+ $esxcli.network.ip.interface.add.Invoke($vmkArgs)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OperationStopped: (:) [], MethodFault
+ FullyQualifiedErrorId : VMware.VimAutomation.Sdk.Types.V1.ErrorHandling.VimException.MethodFault
I'm using PowerCLI 11.3.0 build 13990089.
Do you have any clue on how to achieve this in an automated way without the need of doing it manually from the vSphere Client?
Thank you very much in advance!