Connect-VMNetworkAdapter
Connect-VMNetworkAdapter
Connects a virtual network adapter to a virtual switch.
Syntax
Parameter Set: Name_SwitchName
Connect-VMNetworkAdapter [-VMName] <String[]> [[-Name] <String[]> ] [-SwitchName] <String> [-ComputerName <String[]> ] [-Passthru] [-Confirm] [-WhatIf] [ <CommonParameters>]
Parameter Set: Name_SwitchObject
Connect-VMNetworkAdapter [-VMName] <String[]> [[-Name] <String[]> ] [-VMSwitch] <VMSwitch> [-Passthru] [-Confirm] [-WhatIf] [ <CommonParameters>]
Parameter Set: Name_UseAutomaticConnection
Connect-VMNetworkAdapter [-VMName] <String[]> [[-Name] <String[]> ] -UseAutomaticConnection [-ComputerName <String[]> ] [-Passthru] [-Confirm] [-WhatIf] [ <CommonParameters>]
Parameter Set: Object_SwitchName
Connect-VMNetworkAdapter [-VMNetworkAdapter] <VMNetworkAdapter[]> [-SwitchName] <String> [-Passthru] [-Confirm] [-WhatIf] [ <CommonParameters>]
Parameter Set: Object_SwitchObject
Connect-VMNetworkAdapter [-VMNetworkAdapter] <VMNetworkAdapter[]> [-VMSwitch] <VMSwitch> [-Passthru] [-Confirm] [-WhatIf] [ <CommonParameters>]
Parameter Set: Object_UseAutomaticConnection
Connect-VMNetworkAdapter [-VMNetworkAdapter] <VMNetworkAdapter[]> -UseAutomaticConnection [-Passthru] [-Confirm] [-WhatIf] [ <CommonParameters>]
Detailed Description
The Connect-VMNetworkAdapter cmdlet connects a virtual network adapter to a virtual switch.
Parameters
-ComputerName<String[]>
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.
Aliases |
none |
Required? |
false |
Position? |
named |
Default Value |
. |
Accept Pipeline Input? |
false |
Accept Wildcard Characters? |
false |
-Name<String[]>
Specifies the name of the virtual network adapter to be connected.
Aliases |
VMNetworkAdapterName |
Required? |
false |
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.
Aliases |
none |
Required? |
false |
Position? |
named |
Default Value |
none |
Accept Pipeline Input? |
false |
Accept Wildcard Characters? |
false |
-SwitchName<String>
Specifies the name of the virtual switch to which the virtual network adapter is to be connected.
Aliases |
none |
Required? |
true |
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.
Aliases |
none |
Required? |
true |
Position? |
named |
Default Value |
none |
Accept Pipeline Input? |
false |
Accept Wildcard Characters? |
false |
-VMName<String[]>
Specifies the name of the virtual machine in which the network adapter is to be connected.
Aliases |
none |
Required? |
true |
Position? |
1 |
Default Value |
none |
Accept Pipeline Input? |
false |
Accept Wildcard Characters? |
false |
-VMNetworkAdapter<VMNetworkAdapter[]>
Specifies the virtual network adapter to be connected.
Aliases |
none |
Required? |
true |
Position? |
1 |
Default Value |
none |
Accept Pipeline Input? |
True (ByValue) |
Accept Wildcard Characters? |
false |
-VMSwitch<VMSwitch>
Specifies the virtual switch to which the virtual network adapter is to be connected.
Aliases |
none |
Required? |
true |
Position? |
2 |
Default Value |
none |
Accept Pipeline Input? |
True (ByValue) |
Accept Wildcard Characters? |
false |
-Confirm
Prompts you for confirmation before running the cmdlet.
Required? |
false |
Position? |
named |
Default Value |
false |
Accept Pipeline Input? |
false |
Accept Wildcard Characters? |
false |
-WhatIf
Shows what would happen if the cmdlet runs. The cmdlet is not run.
Required? |
false |
Position? |
named |
Default Value |
false |
Accept Pipeline Input? |
false |
Accept Wildcard Characters? |
false |
<CommonParameters>
This cmdlet supports the common parameters: -Verbose, -Debug, -ErrorAction, -ErrorVariable, -OutBuffer, and -OutVariable. For more information, see about_CommonParameters (https://go.microsoft.com/fwlink/p/?LinkID=113216).
Inputs
The input type is the type of the objects that you can pipe to the cmdlet.
Outputs
The output type is the type of the objects that the cmdlet emits.
- None by default; Microsoft.Virtualization.Powershell.VMNetworkAdapter if –PassThru is specified.
Examples
Example 1
Connects a virtual network adapter named Internet in virtual machines Test1 and Test2 to a virtual switch InternetAccess.
PS C:\> Connect-VMNetworkAdapter -VMName Test1,Test2 -Name Internet -SwitchName InternetAccess
Example 2
Connects a virtual network adapter in virtual machine Test1 to virtual switch InternetAccess.
PS C:\> Get-VMNetworkAdapter –VMName Test1 | Connect-VMNetworkAdapter –SwitchName InternetAccess
Example 3
Connects a virtual network adapter in virtual machine Test1 to switch InternetAccess.
PS C:\> Get-VMSwitch InternetAccess | Connect-VMNetworkAdapter -VMName Test1