So I get the following error when trying to set the portgroup on a network adapter only when I select a portgroup that is on multiple vds.
Command:
Get-VM Server1 | Get-NetworkAdapter | Set-NetworkAdapter -Portgroup "HOST|M1_ANP|COMPUTE_NFS_EPG" -confirm:$false | Out-Null
Error:
Set-NetworkAdapter : 12/11/2020 9:59:13 PM Set-NetworkAdapter The specified parameter 'Portgroup' expects a single value, but your name criteria 'HOST|M1_ANP|COMPUTE_NFS_EPG' corresponds to
multiple values.
At line:1 char:44
+ ... rkAdapter | Set-NetworkAdapter -Portgroup "HOST|M1_ANP|COMPUTE_NFS_EP ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidResult: (System.Collecti...dObjectInterop]:List`1) [Set-NetworkAdapter], VimException
+ FullyQualifiedErrorId : Core_ObnSelector_SelectObjectByNameCore_MoreResultsThanExpected,VMware.VimAutomation.ViCore.Cmdlets.Commands.VirtualDevice.SetNetworkAdapter
Set-NetworkAdapter : 12/11/2020 9:59:13 PM Set-NetworkAdapter Value cannot be found for the mandatory parameter Portgroup
At line:1 char:44
+ ... rkAdapter | Set-NetworkAdapter -Portgroup "HOST|M1_ANP|COMPUTE_NFS_EP ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Set-NetworkAdapter], VimException
+ FullyQualifiedErrorId : Core_BaseCmdlet_UnknownError,VMware.VimAutomation.ViCore.Cmdlets.Commands.VirtualDevice.SetNetworkAdapter
If I remove the duplicate portgroup on a completely different VDS it works with no problem. Is there a way to target the DVS Name and Port group when setting the adapter? I can select it fine through vCenter but my automation script chokes on this command. We have multiple VDS and a few portgroups that span them.
Moderator: Moved to PowerCLI Discussions
Hi @pspacek
You could try something like below.
Get-VDSwitch "vdsname" | Get-VM Server1 | Get-NetworkAdapter | Set-NetworkAdapter -Portgroup "HOST|M1_ANP|COMPUTE_NFS_EPG" -confirm:$false | Out-Null
If you are using OBN, you can have this kind of issue.
Make sure to select the specific portgroup you want.
$pg = Get-VDSwitch -Name MyvDs | Get-VDPortgroup -Name MyvDPg
Get-VM Server1 | Get-NetworkAdapter | Set-NetworkAdapter -Portgroup $pg -confirm:$false | Out-Null
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thanks LucD, this worked perfect... This community is awesome..