Add-VpnConnection
Add-VpnConnection
Adds a VPN connection to the Connection Manager phone book.
Syntax
Parameter Set: Add0
Add-VpnConnection [-Name] <String> [-ServerAddress] <String> [[-TunnelType] <String> ] [[-EncryptionLevel] <String> ] [[-AuthenticationMethod] <String[]> ] [[-SplitTunneling]] [[-AllUserConnection]] [[-L2tpPsk] <String> ] [[-RememberCredential]] [[-UseWinlogonCredential]] [[-EapConfigXmlStream] <XmlDocument> ] [-AsJob] [-CimSession <CimSession[]> ] [-Force] [-PassThru] [-ThrottleLimit <Int32> ] [-Confirm] [-WhatIf] [ <CommonParameters>]
Detailed Description
The Add-VpnConnection cmdlet adds a VPN connection with the specified parameters to the Connection Manager phone book. If errors occur when you create the VPN profile, the error information is returned.
Parameters
-AllUserConnection
Indicates that the VPN connection is added to the global phone book entries.
Aliases |
none |
Required? |
false |
Position? |
8 |
Default Value |
none |
Accept Pipeline Input? |
True (ByPropertyName) |
Accept Wildcard Characters? |
false |
-AsJob
Aliases |
none |
Required? |
false |
Position? |
named |
Default Value |
none |
Accept Pipeline Input? |
false |
Accept Wildcard Characters? |
false |
-AuthenticationMethod<String[]>
Specifies the authentication method to use for the VPN connection. The acceptable values for this parameter are: PAP, CHAP, MSCHAPv2, or EAP.
Aliases |
none |
Required? |
false |
Position? |
6 |
Default Value |
MSChapv2 |
Accept Pipeline Input? |
True (ByPropertyName) |
Accept Wildcard Characters? |
false |
-CimSession<CimSession[]>
Runs the cmdlet in a remote session or on a remote computer. Enter a computer name or a session object, such as the output of a New-CimSession or Get-CimSession cmdlet. The default is the current session on the local computer.
Aliases |
none |
Required? |
false |
Position? |
named |
Default Value |
none |
Accept Pipeline Input? |
false |
Accept Wildcard Characters? |
false |
-EapConfigXmlStream<XmlDocument>
Specifies the contents of the EAP XML configuration file, which includes the EAP method identifier (ID).
Aliases |
none |
Required? |
false |
Position? |
12 |
Default Value |
none |
Accept Pipeline Input? |
True (ByPropertyName) |
Accept Wildcard Characters? |
false |
-EncryptionLevel<String>
Specifies the encryption level for the VPN connection. The acceptable values for this parameter are: NoEncryption, Optional, Required and Maximum.
Aliases |
none |
Required? |
false |
Position? |
5 |
Default Value |
Required |
Accept Pipeline Input? |
True (ByPropertyName) |
Accept Wildcard Characters? |
false |
-Force
Indicates that the pre-shared key (PSK) value is supplied over an insecure channel, if L2TP is used,
Aliases |
none |
Required? |
false |
Position? |
named |
Default Value |
none |
Accept Pipeline Input? |
false |
Accept Wildcard Characters? |
false |
-L2tpPsk<String>
Specifies the value of the PSK to be used for L2TP authentication. If this parameter is not specified, a certificate is used for L2TP.
Aliases |
none |
Required? |
false |
Position? |
9 |
Default Value |
none |
Accept Pipeline Input? |
True (ByPropertyName) |
Accept Wildcard Characters? |
false |
-Name<String>
Specifies the name of this VPN connection profile.
Aliases |
none |
Required? |
true |
Position? |
2 |
Default Value |
none |
Accept Pipeline Input? |
True (ByPropertyName) |
Accept Wildcard Characters? |
false |
-PassThru
Returns an object representing the item with which you are working. By default, this cmdlet does not generate any output.
Aliases |
none |
Required? |
false |
Position? |
named |
Default Value |
none |
Accept Pipeline Input? |
false |
Accept Wildcard Characters? |
false |
-RememberCredential
Indicates that the credentials supplied at the time of first successful connection are stored in the cache.
Aliases |
none |
Required? |
false |
Position? |
10 |
Default Value |
none |
Accept Pipeline Input? |
True (ByPropertyName) |
Accept Wildcard Characters? |
false |
-ServerAddress<String>
Specifies the address of the remote VPN server to which the client connects. You can specify the address as a URL, an IPv4 address, or an IPv6 address.
Aliases |
none |
Required? |
true |
Position? |
3 |
Default Value |
none |
Accept Pipeline Input? |
True (ByPropertyName) |
Accept Wildcard Characters? |
false |
-SplitTunneling
Indicates that split tunneling is enabled for this VPN connection profile. If you do not specify this parameter, split tunneling is disabled.
Aliases |
none |
Required? |
false |
Position? |
7 |
Default Value |
none |
Accept Pipeline Input? |
True (ByPropertyName) |
Accept Wildcard Characters? |
false |
-ThrottleLimit<Int32>
Specifies the maximum number of concurrent operations that can be established to run the cmdlet. If this parameter is omitted or a value of 0
is entered, then Windows PowerShell® calculates an optimum throttle limit for the cmdlet based on the number of CIM cmdlets that are running on the computer. The throttle limit applies only to the current cmdlet, not to the session or to the computer.
Aliases |
none |
Required? |
false |
Position? |
named |
Default Value |
none |
Accept Pipeline Input? |
false |
Accept Wildcard Characters? |
false |
-TunnelType<String>
Specifies the type of tunnel used for the VPN connection. The acceptable values for this parameter are: PPTP, L2TP, SSTP, IKEv2, or Automatic.
Aliases |
none |
Required? |
false |
Position? |
4 |
Default Value |
Automatic |
Accept Pipeline Input? |
True (ByPropertyName) |
Accept Wildcard Characters? |
false |
-UseWinlogonCredential
Indicates that MSCHAPv2 is used as the authentication method, and that Windows logon credentials are used automatically when connecting with this VPN connection profile.
Aliases |
none |
Required? |
false |
Position? |
11 |
Default Value |
none |
Accept Pipeline Input? |
True (ByPropertyName) |
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.
Microsoft.Management.Infrastructure.CimInstance#VpnConnection
The
Microsoft.Management.Infrastructure.CimInstance
object is a wrapper class that displays Windows Management Instrumentation (WMI) objects. The path after the pound sign (#
) provides the namespace and class name for the underlying WMI object.
The VpnConnection object contains the VpnConnection configuration settings.
Examples
EXAMPLExample 1: Add a VPN connectionxample: Add a VPN connection
This command adds a VPN connection named Test1 to the server with an IP address 10.1.1.1. By specifying the Passthru parameter, you can see the configuration of the VPN connection object.
PS C:\> Add-VpnConnection -Name "Test1" -ServerAddress "10.1.1.1" -PassThru
Example 2: Add a VPN connection with an alternate authentication method
This command adds a VPN connection named Test3 to the server with an IP address 10.1.1.1. This connection uses the MSCHAPv2 authentication method, as specified by the AuthenticationMethod parameter. Additional parameters specify that the connection:
-- Uses the Windows logon credentials (the UseWinlogonCredential parameter)
-- Uses split tunneling (the SplitTunneling parameter)
-- Is stored in the global phone book (the AllUserConnection parameter)
-- Caches the credentials used for the first successful connection (the RememberCredential parameter)
By specifying the Passthru parameter, you can see the configuration of the VPN connection object.
PS C:\> Add-VpnConnection -Name "Test3" -ServerAddress "10.1.1.1" -TunnelType Pptp -EncryptionLevel Required -AuthenticationMethod MSChapv2 -UseWinlogonCredential -SplitTunneling -AllUserConnection -RememberCredential -PassThru
EXAMPLE 3
This command adds a VPN connection named Test4 to the server with an IP address of 10.1.1.1. This connection uses the default EAP authentication method, as specified by the AuthenticationMethod parameter. The pre-shared key for the connection, password, is specified by the L2tpPsk parameter Additional parameters specify that the connection:
-- Uses split tunneling (the SplitTunneling parameter)
-- Is stored in the global phone book (the AllUserConnection parameter)
-- Caches the credentials used for the first successful connection (the RememberCredential parameter)
By specifying the Passthru parameter, you can see the configuration of the VPN connection object.
PS C:\> Add-VpnConnection -Name "Test4" -ServerAddress "10.1.1.1" -TunnelType L2tp -EncryptionLevel Required -AuthenticationMethod Eap -SplitTunneling -AllUserConnection -L2tpPsk "password" -Force -RememberCredential -PassThru
EXAMPLE 4
This set of commands adds a VPN connection using a custom EAP authentication method. For more information about custom EAP authentication methods, see the New-EapConfiguration cmdlet.
This command stores the result of the New-EapConfiguration cmdlet into the variable named $a.
PS C:\> $a = New-EapConfiguration
This command adds a new VPN connection named Test5 to the server with an IP address of 10.1.1.1. This connection is configured to use the custom EAP authentication method specifying the EapConfigXmlStream parameter, and using the EapConfigXmlStream method of the $a variable created earlier. Additional parameters specify that the connection:
-- Uses split tunneling (the SplitTunneling parameter)
-- Is stored in the global phone book (the AllUserConnection parameter)
-- Caches the credentials used for the first successful connection (the RememberCredential parameter)
By specifying the Passthru parameter, you can see the configuration of the VPN connection object.
PS C:\> Add-VpnConnection -Name "Test5" -ServerAddress "10.1.1.1" -TunnelType L2tp -EncryptionLevel Required -AuthenticationMethod Eap -SplitTunneling -AllUserConnection -RememberCredential -EapConfigXmlStream $a.EapConfigXmlStream -PassThru