## 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

Name | Type | Description | Required? | Pipeline Input | Default Value
--- | --- | --- | --- | --- | ---
VM | VirtualMachine | Specifies the virtual machine to which you want to attach the new virtual network adapter. Passing multiple values to this parameter is obsolete. | true | true (ByValue)
Confirm | SwitchParameter | If 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. | false | false
DistributedSwitch | DistributedSwitch | Specifies a virtual switch to which you want to connect the network adapter. | true | false
MacAddress | String | Specifies an optional MAC address for the new virtual network adapter. | false | false
NetworkName | String | Specifies 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. | true | false
Portgroup | VirtualPortGroupBase | Specifies a standard or a distributed port group to which you want to connect the new network adapter. | true | false
PortId | String | Specifies 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. | true | false
Server | VIServer[] | 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. | false | false
StartConnected | SwitchParameter | Indicates that the virtual network adapter starts connected when the virtual machine associated with it powers on. | false | false
Type | VirtualNetworkAdapterType | Specifies 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. | false | false
WakeOnLan | SwitchParameter | Indicates that wake-on-LAN is enabled on the newly created virtual network adapter. | false | false
WhatIf | SwitchParameter | Indicates that the cmdlet is run only to display the changes that would be made and actually no objects are modified. | false | false

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.