Connect-VMNetworkAdapter
Connects a virtual network adapter to a virtual switch.
Syntax
Connect-VMNetworkAdapter
[-VMName] <String[]>
[-ComputerName <String[]>]
[[-Name] <String[]>]
[-SwitchName] <String>
[-Passthru]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Connect-VMNetworkAdapter
[-VMName] <String[]>
[[-Name] <String[]>]
[-VMSwitch] <VMSwitch>
[-Passthru]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Connect-VMNetworkAdapter
[-VMName] <String[]>
[-ComputerName <String[]>]
[[-Name] <String[]>]
[-UseAutomaticConnection]
[-Passthru]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Connect-VMNetworkAdapter
[-VMNetworkAdapter] <VMNetworkAdapter[]>
[-UseAutomaticConnection]
[-Passthru]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Connect-VMNetworkAdapter
[-VMNetworkAdapter] <VMNetworkAdapter[]>
[-VMSwitch] <VMSwitch>
[-Passthru]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Connect-VMNetworkAdapter
[-VMNetworkAdapter] <VMNetworkAdapter[]>
[-SwitchName] <String>
[-Passthru]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
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.
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: | . |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-Confirm
Prompts you for confirmation before running the cmdlet.
Type: | SwitchParameter |
Aliases: | cf |
Position: | Named |
Default value: | False |
Required: | 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: | 1 |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-Passthru
Specifies that a Microsoft.HyperV.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 |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-SwitchName
Specifies the name of the virtual switch to which the virtual network adapter is to be connected.
Type: | String |
Position: | 1 |
Default value: | None |
Required: | True |
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 |
Required: | True |
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: | 0 |
Default value: | None |
Required: | True |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-VMNetworkAdapter
Specifies the virtual network adapter to be connected.
Type: | VMNetworkAdapter[] |
Position: | 0 |
Default value: | None |
Required: | True |
Accept pipeline input: | True |
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 |
Required: | True |
Accept pipeline input: | True |
Accept wildcard characters: | False |
-WhatIf
Shows what would happen if the cmdlet runs. The cmdlet is not run.
Type: | SwitchParameter |
Aliases: | wi |
Position: | Named |
Default value: | False |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
Outputs
None by default; Microsoft.HyperV.PowerShell.VMNetworkAdapter if -PassThru is specified.
Feedback
Submit and view feedback for