PowerCLI Reference

Set-NetworkAdapter

Synopsis

This cmdlet modifies the configuration of the virtual network adapter.

Syntax

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

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

Set-NetworkAdapter [-NetworkAdapter] <NetworkAdapter[]> -Portgroup <VirtualPortGroupBase> [-RunAsync] [-Server <VIServer[]>] [-Confirm] [-WhatIf] [<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.