Set-NetworkAdapter Command | Vmware PowerCLI Reference

Set-NetworkAdapter

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.

Syntax

Set-NetworkAdapter
-DistributedSwitch < DistributedSwitch >
-NetworkAdapter < NetworkAdapter[] >
-PortId < String >
[-Connected < Boolean > ]
[-MacAddress < String > ]
[-ProgressAction < ActionPreference > ]
[-RunAsync ]
[-Server < VIServer[] > ]
[-StartConnected < Boolean > ]
[-WakeOnLan < Boolean > ]
[CommonParameters]

Parameters

Required Parameter Name Type Position Features Description
required
DistributedSwitch DistributedSwitch named
  • wildcards
Specifies a virtual switch to which you want to connect the network adapter.
required
NetworkAdapter NetworkAdapter[] named
  • pipeline
Specifies the virtual network adapter you want to configure.
required
PortId String named
Specifies 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.
optional Connected Boolean named
If the value is $true, the virtual network adapter is connected after its creation. If the value is $false, it is disconnected.
optional MacAddress String named
Specifies an optional MAC address for the virtual network adapter.
optional ProgressAction ActionPreference named
optional RunAsync SwitchParameter named
Indicates 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.
optional Server VIServer[] named
  • wildcards
Specifies the vCenter Server systems on which you want to run the cmdlet. If no value is provided or $null 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.
optional StartConnected Boolean named
If 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.
optional Type VirtualNetworkAdapterType named
Specifies the type of the network adapter. The valid types are e1000, Flexible, Vmxnet, EnhancedVmxnet, and Vmxnet3, and Unknown.
optional WakeOnLan Boolean named
Indicates that wake-on-LAN is enabled on the virtual network adapter.
Set-NetworkAdapter
-NetworkAdapter < NetworkAdapter[] >
-Portgroup < VirtualPortGroupBase >
[-ProgressAction < ActionPreference > ]
[-RunAsync ]
[-Server < VIServer[] > ]
[CommonParameters]

Parameters

Required Parameter Name Type Position Features Description
required
NetworkAdapter NetworkAdapter[] named
  • pipeline
Specifies the virtual network adapter you want to configure.
required
Portgroup VirtualPortGroupBase named
Specifies a standard or a distributed port group to which you want to connect the network adapter.
optional ProgressAction ActionPreference named
optional RunAsync SwitchParameter named
Indicates 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.
optional Server VIServer[] named
  • wildcards
Specifies the vCenter Server systems on which you want to run the cmdlet. If no value is provided or $null 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.
Set-NetworkAdapter
-NetworkAdapter < NetworkAdapter[] >
[-Connected < Boolean > ]
[-MacAddress < String > ]
[-NetworkName < String > ]
[-ProgressAction < ActionPreference > ]
[-RunAsync ]
[-Server < VIServer[] > ]
[-StartConnected < Boolean > ]
[-WakeOnLan < Boolean > ]
[CommonParameters]

Parameters

Required Parameter Name Type Position Features Description
required
NetworkAdapter NetworkAdapter[] named
  • pipeline
Specifies the virtual network adapter you want to configure.
optional Connected Boolean named
If the value is $true, the virtual network adapter is connected after its creation. If the value is $false, it is disconnected.
optional MacAddress String named
Specifies an optional MAC address for the virtual network adapter.
optional NetworkName String named
Specifies 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.
optional ProgressAction ActionPreference named
optional RunAsync SwitchParameter named
Indicates 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.
optional Server VIServer[] named
  • wildcards
Specifies the vCenter Server systems on which you want to run the cmdlet. If no value is provided or $null 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.
optional StartConnected Boolean named
If 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.
optional Type VirtualNetworkAdapterType named
Specifies the type of the network adapter. The valid types are e1000, Flexible, Vmxnet, EnhancedVmxnet, and Vmxnet3, and Unknown.
optional WakeOnLan Boolean named
Indicates that wake-on-LAN is enabled on the virtual network adapter.

Output

VMware.VimAutomation.ViCore.Types.V1.VirtualDevice.NetworkAdapter

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.

Related Commands

NetworkAdapter

This cmdlet retrieves the virtual network adapters available on a vCenter Server system.

This cmdlet creates a new virtual network adapter.

This cmdlet removes the virtual network adapters from their locations.

This cmdlet modifies the configuration of the virtual network adapter.