I am looking for a command to add new Network card to the VM.
Yes, the NetworkName parameter is a required parameter.
So you have to provide an existing portgroup.
I normally use a 'dummy' portgroup for that, and only set the final portgroup later on.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
See New-NetworkAdapter.
You'll have to repeat the cmdlet for multiple vNICs.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hi LUcD,
We did try that, but received the error as
New-NetworkAdapter -VM $vm_details.Name -NetworkName "custom_nw_10.78.215.XX" -Type e1000 -StartConnected -WakeOnLan
New-NetworkAdapter : 6/26/2019 10:59:37 AM New-NetworkAdapter The network "custom_nw_10.78.215.XX" doesn't exist on the host.
At line:1 char:1
+ New-NetworkAdapter -VM $vm_details.Name -NetworkName "custom_nw_10.78 ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ResourceUnavailable: (custom_nw_10.78.215.XX:String) [New-NetworkAdapter], ViError
+ FullyQualifiedErrorId : Client20_VmHostServiceImpl_TryGetHostNetworkByName_NonexistentNetwork,VMware.VimAutomation.ViCore.Cmdlets.Commands.VirtualDevice.NewNetworkAdapter
It looks as if that portgroup doesn't exist in your environment.
Is that name included in the list when you do a Get-VirtualPortgroup
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
No, it doesnt contain. Do i need to add that first?
The purpose here is to add just a nic 1 wih no network connected.
Yes, the NetworkName parameter is a required parameter.
So you have to provide an existing portgroup.
I normally use a 'dummy' portgroup for that, and only set the final portgroup later on.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
And you can use the StartConnected parameter to make sure the vNic is not connected.
New-NetworkAdapter -Type Vmxnet3 -NetworkName Dummy -StartConnected:$false
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference