1

I am using the PowerCLI version 12 and have a VM which currently has no network adapter.

There is the Cmdlet Get-CINetworkAdapter but that returns null (because there is no adapter) And there is Set-CINetworkAdapter but again without a CINetworkAdapter to pass in this doesn't work.

Is there a New-CINetworkAdapter I am missing somewhere?

1 Answer 1

1

This is currently the code I am using to do this:

$NIC = New-Object -TypeName 'VMware.VimAutomation.Cloud.Views.OvfRASD' $NIC.AddressOnParent = '0' $NIC.AutomaticAllocation = New-Object -TypeName 'VMware.VimAutomation.Cloud.Views.CimBoolean' $NIC.AutomaticAllocation.Value = $true $NICConnectionString = New-Object -TypeName 'VMware.VimAutomation.Cloud.Views.CimString' $connectionAttributes = New-Object 'VMware.VimAutomation.Cloud.Views.XmlAttributeCollection' $connectionAttributes.Add('ns5','ipAddressingMode','http://www.vmware.com/vcloud/v1.5','POOL') $connectionAttributes.Add('ns5','primaryNetworkConnection','http://www.vmware.com/vcloud/v1.5','true') $NICConnectionString.AnyAttr = $connectionAttributes $NICConnectionString.Value = 'None' $NIC.Connection = $NICConnectionString $NIC.Description = 'VMXNET3 ethernet adapter on ''none''' $NIC.ElementName = 'Network adapter 0' $NIC.InstanceID = '0' $NIC.ResourceSubType = 'VMXNET3' $NICResourceType = New-Object -TypeName 'VMware.VimAutomation.Cloud.Views.CimRASDResource' $NICResourceType.Value = '10' $NIC.ResourceType = $NICResourceType $vm = Get-CIVM -Name '[VM Name]' $vmVirtualHardwareSection = $vm.ExtensionData.GetVirtualHardwareSection() $vmNetworkCards = $vmVirtualHardwareSection.GetNetworkCards() $vmNetworkCards.Item = $NIC $vmNetworkCards.UpdateServerData() 

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.