PowerCLI Reference

Set-NetworkAdapter

Synopsis

This cmdlet modifies the configuration of the virtual network adapter.

Syntax

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

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

Set-NetworkAdapter [-NetworkAdapter] <NetworkAdapter[]> -Portgroup <VirtualPortGroupBase> [-RunAsync] [-Server <VIServer[]>] [-WhatIf] [-Confirm] [<CommonParameters>]

Related Commands

Online version
Get-NetworkAdapter
New-NetworkAdapter
Remove-NetworkAdapter

Detailed Description

This cmdlet modifies 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[]Specifies 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
ConnectedBooleanIf the value is $true, the virtual network adapter is connected after its creation. If the value is $false, it is disconnected.falsefalse
DistributedSwitchDistributedSwitchSpecifies a virtual switch to which you want to connect the network adapter.truefalse
MacAddressStringSpecifies an optional MAC address for the virtual network adapter.falsefalse
NetworkNameStringSpecifies the name of the network to which you want to connect the virtual network adapter. Specifying a distributed port group name is obsolete. Use the Portgroup parameter instead.falsefalse
PortgroupVirtualPortGroupBaseSpecifies a standard or a distributed port group to which you want to connect the network adapter.truefalse
PortIdStringSpecifies the port of the virtual switch to which you want to connect the network adapter. Use this parameter only if the DistributedSwitch parameter is specified.truefalse
RunAsyncSwitchParameterIndicates that the command returns immediately without waiting for the task to complete. In this mode, the output of the cmdlet is a Task object. For more information about the RunAsync parameter run "help About_RunAsync" in the VMware PowerCLI console.falsefalse
ServerVIServer[]Specifies the vCenter Server systems 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
TypeVirtualNetworkAdapterTypeSpecifies the type of the network adapter. The valid types are e1000, Flexible, Vmxnet, EnhancedVmxnet, and Vmxnet3, and Unknown.falsefalse
WakeOnLanBooleanIndicates that wake-on-LAN is enabled on the 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

Zero or more modified NetworkAdapter objcts

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

$myNetworkAdapters = Get-VM | Get-NetworkAdapter -Name "Network adapter 1"
$myVDPortGroup = Get-VDPortgroup -Name MyVDPortGroup
Set-NetworkAdapter -NetworkAdapter $myNetworkAdapters -Portgroup $myVDPortGroup

Retrieves all network adapters named "Network adapter 1" from all virtual machines and connects them to the specified distributed port group.

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

$myNetworkAdapter = Get-VM -Name MyVM | Get-NetworkAdapter -Name "Network adapter 1"
$myVDSwitch = Get-VDSwitch -Name MyVDSwitch
Set-NetworkAdapter -NetworkAdapter $myNetworkAdapter -DistributedSwitch $MyVDSwitch -PortId 100

Retrieves the network adapter named "Network adapter 1" added to the specified virtual machine and connects it to the specified port on the specified distributed switch.


Copyright © VMware, Inc. All rights reserved.