PowerCLI Reference

New-NetworkAdapter

Synopsis

This cmdlet creates a new virtual network adapter.

Syntax

New-NetworkAdapter [-MacAddress <String>] -NetworkName <String> [-StartConnected] [-WakeOnLan] [-Type <VirtualNetworkAdapterType>] [-VM] <VirtualMachine[]> [-Server <VIServer[]>] [-WhatIf] [-Confirm] [<CommonParameters>]
New-NetworkAdapter [-MacAddress <String>] [-StartConnected] [-WakeOnLan] [-Type <VirtualNetworkAdapterType>] -PortId <String> -DistributedSwitch <DistributedSwitch> [-VM] <VirtualMachine[]> [-Server <VIServer[]>] [-WhatIf] [-Confirm] [<CommonParameters>]
New-NetworkAdapter [-MacAddress <String>] [-StartConnected] [-WakeOnLan] [-Type <VirtualNetworkAdapterType>] -Portgroup <VirtualPortGroupBase> [-VM] <VirtualMachine[]> [-Server <VIServer[]>] [-WhatIf] [-Confirm] [<CommonParameters>]

Related Commands

Online version
Get-NetworkAdapter
Remove-NetworkAdapter
Set-NetworkAdapter

Detailed Description

This cmdlet creates a new virtual network adapter for each of the provided virtual machines and sets the optional properties if provided.

Parameters

NameTypeDescriptionRequired?Pipeline InputDefault Value
VMVirtualMachine[]Specifies the virtual machine to which you want to attach the new virtual network adapter. Passing multiple values to this parameter is obsolete.truetrue (ByValue)
ConfirmSwitchParameterIf the value is $true, indicates that the cmdlet asks for confirmation before running. If the value is $false, the cmdlet runs without asking for user confirmation.falsefalse
DistributedSwitchDistributedSwitchSpecifies a virtual switch to which you want to connect the network adapter.truefalse
MacAddressStringSpecifies an optional MAC address for the new virtual network adapter.falsefalse
NetworkNameStringSpecifies the name of the network to which you want to add the new virtual network adapter. Specifying a distributed port group name is obsolete. Use the Portgroup parameter instead.truefalse
PortgroupVirtualPortGroupBaseSpecifies a standard or a distributed port group to which you want to connect the new network adapter.truefalse
PortIdStringSpecifies the port of the specified distributed switch to which you want to connect the network adapter. Use this parameter only if the DistributedSwitch parameter is specified.truefalse
ServerVIServer[]Specifies the vCenter Server systems on which you want to run the cmdlet. If no value is passed to this parameter, the command runs on the default servers. For more information about default servers, see the description of Connect-VIServer.falsefalse
StartConnectedSwitchParameterIndicates that the virtual network adapter starts connected when the virtual machine associated with it powers on.falsefalse
TypeVirtualNetworkAdapterTypeSpecifies the type of the new network adapter. The valid types are e1000, Flexible, Vmxnet, EnhancedVmxnet, and Vmxnet3, and Unknown. If no value is given to the parameter, the new network adapter is of the type recommended by VMware for the given guest OS.falsefalse
WakeOnLanSwitchParameterIndicates that wake-on-LAN is enabled on the newly created virtual network adapter.falsefalse
WhatIfSwitchParameterIndicates that the cmdlet is run only to display the changes that would be made and actually no objects are modified.falsefalse

Return Type

The one or more newly created NetworkAdapter objects

Notes

There are two special cases concerning the behavior of New-NetworkAdapter: - If you are directly connected to a standalone ESX host (that is not managed by a vCenter Server), the MAC address of the newly created network adapter is generated after the associated virtual machine is powered on for a first time. - If you are directly connected to an ESX host that is managed by a vCenter Server, the MAC address of the newly created network adapter is generated with a delay of several seconds.

Examples

-------------- Example 1 --------------

Get-VM VM | New-NetworkAdapter  -NetworkName "VM Network" -MacAddress '00:50:56:a1:00:00' -WakeOnLan -StartConnected -Type EnhancedVmxnet

Create a virtual network adapter with the specified parameters.

-------------- Example 2 --------------

$myVm = Get-VM -Name MyVM
$MyVDPortgroup = Get-VDPortgroup -Name MyVDPortGroup
New-NetworkAdapter -VM $myVM -Portgroup $MyVDPortgroup

Adds a new network adapter to the specified virtual machine and connects it to the specified distributed port group.

-------------- Example 3 --------------

$myVM = Get-VM -Name MyVM
$MyVDSwitch = Get-VDSwitch -Name MyVDSwitch
New-NetworkAdapter -VM $myVM -DistributedSwitch $MyVDSwitch -PortId 100

Adds a new network adapter to the specified virtual machine and connects it to the specified port on the specified vSphere distributed switch.


Copyright © VMware, Inc. All rights reserved.