Automation

 View Only

 Add VMkernel to vDS Portgroup

Jump to Best Answer
pamiller21's profile image
pamiller21 posted Jun 21, 2024 02:09 PM

I am trying to make a script to add a vmKernal to a vDS Portgroup but I am getting an error message that I don't understand.

PS /root> $pg999 = "10.111.0.0%2F20-DATA999"
PS /root> $pg999
10.111.0.0%2F20-DATA999
PS /root> New-VMHostNetworkAdapter -VMHost $vHost -PortGroup $pg999 -VirtualSwitch $vDS -IP $DATA999IP -SubnetMask 255.255.240.0 -confirm:$false
New-VMHostNetworkAdapter: 6/21/2024 1:04:10 PM  New-VMHostNetworkAdapter                An error occured but the error message cannot be loaded. The error Id is ViCore_Extensions_ValidateForVNicConnection_NotValidPortgroupType

LucD's profile image
LucD Best Answer

Do you have multiple connections to the VCSA open?
Check what is $global:defaultVIServers

LucD's profile image
LucD

Did you try getting the Portgroup object, and then using that as the value?

$pg = Get-VDPortgroup -VDSwitch $vDS -Name $pg999
New-VMHostNetworkAdapter -VMHost $vHost -PortGroup $pg -VirtualSwitch $vDS -IP $DATA999IP -SubnetMask 255.255.240.0 -confirm:$false
pamiller21's profile image
pamiller21

PS /root> $pg999 = "10.111.0.0/20-DATA999"
PS /root> $pg = Get-VDPortgroup -VDSwitch $vDS -Name $pg999
PS /root> New-VMHostNetworkAdapter -VMHost $vHost -PortGroup $pg -VirtualSwitch $vDS -IP $DATA999IP -SubnetMask 255.255.240.0 -confirm:$false
New-VMHostNetworkAdapter: Cannot convert 'System.Object[]' to the type 'System.String' required by parameter 'PortGroup'. Specified method is not supported.

LucD's profile image
LucD

Looks like Get-VDPortgroup is returning more than 1 Portgroup, hence the 'System.Object[]' 
That might be the cause of the original error as well

pamiller21's profile image
pamiller21

You seem right, I run this Get-VDPortGroup -VDSwitch $vDS and I see 2, but if I look visually I only see one. Why tho?

pamiller21's profile image
pamiller21

That was it, so sorry I should have seen I had it connected twice.