vSphere PowerCLI Reference

Set-NetworkAdapter

Synopsis

Changes the configuration of the virtual network adapter.

Syntax

Set-NetworkAdapter [-NetworkAdapter] <NetworkAdapter[]> [-MacAddress <String>] [-NetworkName <String>] [-StartConnected [<Boolean>]] [-Connected [<Boolean>]] [-WakeOnLan [<Boolean>]] [-Type <VirtualNetworkAdapterType>] [-PortKey <String>] [-DistributedSwitch <DistributedSwitch>] [-Server <VIServer[]>] [-WhatIf] [-Confirm] [<CommonParameters>]

Related Commands

Online version
Get-NetworkAdapter
New-NetworkAdapter
Remove-NetworkAdapter

Detailed Description

Changes the configuration of the virtual network adapter. You can change the MAC address and the network name, and to configure the Connected, StartConnected, and WakeOnLan properties of the adapter.

Parameters

NameTypeDescriptionRequired?Pipeline InputDefault Value
NetworkAdapterNetworkAdapter[]Specify the virtual network adapter you want to configure.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
ConnectedBooleanIf the value is $true, the virtual network adapter is connected after its creation. If the value is $false, it is disconnected.falsefalse
DistributedSwitchDistributedSwitchSpecify a virtual switch to which you want to connect the network adapter.falsefalse
MacAddressStringSpecify an optional MAC address for the virtual network adapter.falsefalse
NetworkNameStringSpecify the name of the network to which you want to connect the virtual network adapter.falsefalse
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.falsefalse
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
StartConnectedBooleanIf the value is $true, the virtual network adapter starts connected when its associated virtual machine powers on. If the value is $false, it starts disconnected.falsefalse
TypeVirtualNetworkAdapterTypeSpecify the type of the network adapter. The valid types are e1000, Flexible, Vmxnet, EnhancedVmxnet, and Vmxnet3, and Unknown.falsefalse
WakeOnLanBooleanIndicate that wake-on-LAN is enabled on the 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

Examples

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

Get-VM VM | Get-NetworkAdapter | Set-NetworkAdapter -MacAddress '00:50:56:a1:00:00' -WakeOnLan:$true

Configures the Mac address and the WakeOnLan setting of a virtual network adapter.

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

Get-VM VM | Get-NetworkAdapter | Set-NetworkAdapter -Type EnhancedVmxnet

Sets the type of the virtual network adapter.

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

Get-VM VM | Get-NetworkAdapter | Set-NetworkAdapter -Connected:$true

Sets the connection state of the virtual network adapter.

-------------- Example 4 --------------

$distributedSwitch = Get-VirtualSwitch -Distributed -Name DistributedSwitch

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

Connects a virtual network adapter to a distributed switch by specifying an available port key.

-------------- Example 5 --------------

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

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

Connects a virtual network adapter to a distributed switch by specifying the network name.


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