powershellscripts.com

Tutorials  PowerShell Cmdlet Help for New-NetworkAdapter



NAME
New-NetworkAdapter

SYNOPSIS
Creates a new virtual network adapter.

SYNTAX
New-NetworkAdapter [-MacAddress ] -NetworkName [-StartConnected] [-WakeOnLan] [-Type rkAdapterType>] [-VM] [-Server ] [-WhatIf] [-Confirm] []

New-NetworkAdapter [-MacAddress ] [-StartConnected] [-WakeOnLan] [-Type ] -PortK
ey -DistributedSwitch [-VM] [-Server ] [-WhatIf] [-Conf
irm] []


DESCRIPTION
Creates a new virtual network adapter for each of the provided virtual machines and sets the optional properties if
provided.


PARAMETERS
-MacAddress
Specify an optional MAC address for the new virtual network adapter.

Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false

-NetworkName
Specify the name of the network to which you want to add the new virtual network adapter.

Required? true
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false

-StartConnected
Indicate that the virtual network adapter starts connected when the virtual machine associated with it powers o
n.

Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false

-WakeOnLan
Indicate that wake-on-LAN is enabled on the newly created virtual network adapter.

Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false

-Type
Specify the type of the new network adapter. The valid types are e1000, Flexible, Vmxnet, EnhancedVmxnet, and V
mxnet3, 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.

Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false

-VM
Specify the virtual machines to which you want to attach the new virtual network adapter.

Required? true
Position? 1
Default value
Accept pipeline input? true (ByValue)
Accept wildcard characters? true

-Server
Specify the vSphere servers on which you want to run the cmdlet. If no value is given to this parameter, the co
mmand runs on the default servers. For more information about default servers, see the description of Connect-V
IServer.

Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? true

-WhatIf
Indicate that the cmdlet is run only to display the changes that would be made and actually no objects are modi
fied.

Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false

-Confirm
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.

Required? false
Position? named
Default value $true
Accept pipeline input? false
Accept wildcard characters? false

-PortKey
Specify the port of the virtual switch to which you want to connect the network adapter. Use this parameter onl
y if the -VirtualSwitch parameter is specified.

Required? true
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false

-DistributedSwitch
Specify a virtual switch to which you want to connect the network adapter.

Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? true


This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

INPUTS



OUTPUTS
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 managed by a vCenter Server), the MAC add
ress 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 newl
y created network adapter is generated with a delay of several seconds.

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

C:\PS>Get-VM VM | New-NetworkAdapter -NetworkName "VM Network" -MacAddress '00:50:56:a1:00:00' -WakeOnLan -StartCo
nnected -Type EnhancedVmxnet


Create a virtual network adapter with the specified parameters.





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

C:\PS>$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 --------------

C:\PS>$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.






RELATED LINKS
Online version: http://www.vmware.com/support/developer/PowerCLI/PowerCLI501/html/New-NetworkAdapter.html
Get-NetworkAdapter
Remove-NetworkAdapter
Set-NetworkAdapter