Connect-VMNetworkAdapter

Connects a virtual network adapter to a virtual switch.

Syntax

Connect-VMNetworkAdapter
       [-VMName] <String[]>
       [[-Name] <String[]>]
       [-SwitchName] <String>
       [-ComputerName <String[]>]
       [-Passthru]
       [-Confirm]
       [-WhatIf]
Connect-VMNetworkAdapter
       [-VMName] <String[]>
       [[-Name] <String[]>]
       [-ComputerName <String[]>]
       [-Passthru]
       [-UseAutomaticConnection]
       [-Confirm]
       [-WhatIf]
Connect-VMNetworkAdapter
       [-VMName] <String[]>
       [[-Name] <String[]>]
       [-VMSwitch] <VMSwitch>
       [-Passthru]
       [-Confirm]
       [-WhatIf]
Connect-VMNetworkAdapter
       [-VMNetworkAdapter] <VMNetworkAdapter[]>
       [-SwitchName] <String>
       [-Passthru]
       [-Confirm]
       [-WhatIf]
Connect-VMNetworkAdapter
       [-VMNetworkAdapter] <VMNetworkAdapter[]>
       [-Passthru]
       [-UseAutomaticConnection]
       [-Confirm]
       [-WhatIf]
Connect-VMNetworkAdapter
       [-VMNetworkAdapter] <VMNetworkAdapter[]>
       [-VMSwitch] <VMSwitch>
       [-Passthru]
       [-Confirm]
       [-WhatIf]

Description

The Connect-VMNetworkAdapter cmdlet connects a virtual network adapter to a virtual switch.

Examples

Example 1

PS C:\>Connect-VMNetworkAdapter -VMName Test1,Test2 -Name Internet -SwitchName InternetAccess

Connects a virtual network adapter named Internet in virtual machines Test1 and Test2 to a virtual switch InternetAccess.

Example 2

PS C:\>Get-VMNetworkAdapter -VMName Test1 | Connect-VMNetworkAdapter -SwitchName InternetAccess

Connects a virtual network adapter in virtual machine Test1 to virtual switch InternetAccess.

Example 3

PS C:\>Get-VMSwitch InternetAccess | Connect-VMNetworkAdapter -VMName Test1

Connects a virtual network adapter in virtual machine Test1 to switch InternetAccess.

Required Parameters

-SwitchName

Specifies the name of the virtual switch to which the virtual network adapter is to be connected.

Type:String
Position:3
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-UseAutomaticConnection

Specifies that the network adapter is to be connected to any virtual switch in the resource pool, rather than to a specific virtual switch.

Type:SwitchParameter
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-VMName

Specifies the name of the virtual machine in which the network adapter is to be connected.

Type:String[]
Position:1
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-VMNetworkAdapter

Specifies the virtual network adapter to be connected.

Type:VMNetworkAdapter[]
Position:1
Default value:None
Accept pipeline input:True (ByValue)
Accept wildcard characters:False
-VMSwitch

Specifies the virtual switch to which the virtual network adapter is to be connected.

Type:VMSwitch
Position:2
Default value:None
Accept pipeline input:True (ByValue)
Accept wildcard characters:False

Optional Parameters

-ComputerName

Specifies one or more virtual machine hosts on which the virtual network adapter is to be connected. NetBIOS names, IP addresses, and fully-qualified domain names are allowable. The default is the local computer - use "localhost" or a dot (".") to specify the local computer explicitly.

Type:String[]
Position:Named
Default value:.
Accept pipeline input:False
Accept wildcard characters:False
-Confirm

Prompts you for confirmation before running the cmdlet.

Type:SwitchParameter
Position:Named
Default value:False
Accept pipeline input:False
Accept wildcard characters:False
-Name

Specifies the name of the virtual network adapter to be connected.

Type:String[]
Aliases:VMNetworkAdapterName
Position:2
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-Passthru

Specifies that a Microsoft.Virtualization.Powershell.VMNetworkAdapter object is to be passed through to the pipeline representing the virtual network adapter to be connected.

Type:SwitchParameter
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-WhatIf

Shows what would happen if the cmdlet runs. The cmdlet is not run.

Type:SwitchParameter
Position:Named
Default value:False
Accept pipeline input:False
Accept wildcard characters:False

Outputs

None by default; Microsoft.Virtualization.Powershell.VMNetworkAdapter if -PassThru is specified.