Hi,
I'm trying to script vmkernel creation with 5 IP addresses assigned and have the following script.
$esxiHosts = @("esxi21.v.lab", "esxi22.v.lab", "esxi23.v.lab", "esxi24.v.lab", "esxi25.v.lab")
foreach ($i in 31..35)
{
$ipa = "192.168.2.$i"
$vSwitch = Get-VirtualSwitch -VMHost $esxiHosts -Name vSwitch0
New-VMHostNetworkAdapter -VMhost $esxiHosts -PortGroup ManagementNetwork2 -IP $ipa -subnetmask 255.255.255.0 -VirtualSwitch $vSwitch -ManagementTrafficEnabled $true
}
However, am running into the error below, and have exhausted trying to find a solution.
New-VMHostNetworkAdapter : Cannot convert 'System.Object[]' to the type 'VMware.VimAutomation.ViCore.Types.V1.Inventory.VMHost' required by parameter 'VMHost'. Specified
method is not supported.
At line:5 char:34
+ New-VMHostNetworkAdapter -VMhost $esxiHosts -PortGroup ManagementNetw ...
+ ~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [New-VMHostNetworkAdapter], ParameterBindingException
+ FullyQualifiedErrorId : CannotConvertArgument,VMware.VimAutomation.ViCore.Cmdlets.Commands.Host.NewVMHostNetworkAdapter
Any thoughts, thank you.