vSphere PowerCLI Reference

New-NetworkAdapter

Synopsis

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>] -PortKey <String> -DistributedSwitch <DistributedSwitch> [-VM] <VirtualMachine[]> [-Server <VIServer[]>] [-WhatIf] [-Confirm] [<CommonParameters>]

Related Commands

Online version
Get-NetworkAdapter
Remove-NetworkAdapter
Set-NetworkAdapter

Detailed Description

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[]Specify the virtual machines to which you want to attach the new virtual network adapter.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$true
DistributedSwitchDistributedSwitchSpecify a virtual switch to which you want to connect the network adapter.truefalse
MacAddressStringSpecify an optional MAC address for the new virtual network adapter.falsefalse
NetworkNameStringSpecify the name of the network to which you want to add the new virtual network adapter.truefalse
PortKeyStringSpecify the port of the virtual switch to which you want to connect the network adapter. Use this parameter only if the -VirtualSwitch parameter is specified.truefalse
ServerVIServer[]Specify the vSphere servers on which you want to run the cmdlet. If no value is given to this parameter, the command runs on the default servers. For more information about default servers, see the description of Connect-VIServer.falsefalse
StartConnectedSwitchParameterIndicate that the virtual network adapter starts connected when the virtual machine associated with it powers on.falsefalse
TypeVirtualNetworkAdapterTypeSpecify 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
WakeOnLanSwitchParameterIndicate that wake-on-LAN is enabled on the newly created virtual network adapter.falsefalse
WhatIfSwitchParameterIndicate that the cmdlet is run only to display the changes that would be made and actually no objects are modified.falsefalse

Return Type

NetworkAdapter

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 manag ed by a vCenter Server), the MAC address of the newly created network adapt er is generated after the associated virtual machine is powered on for a fi rst 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 --------------

$distributedSwitch = Get-VirtualSwitch -Distributed -Name DistributedSwitch

Get-VM VM | New-NetworkAdapter -PortKey 100 -DistributedSwitch $distributedSwitch

Create a virtual network adapter on a distributed switch by specifying an available port key.

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

$distributedSwitchPortGroup = Get-VirtualSwitch -Distributed -Name DistributedSwitch | Get-VirtualPortGroup -Name PortGroup

Get-VM VM | New-NetworkAdapter -NetworkName $distributedSwitchPortGroup.Name

Create a virtual network adapter on a distributed switch by specifying the network name.


Copyright © 1998 - 2012 VMware, Inc. All rights reserved.