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 cmdlet returns the error information.
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.
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.
Example 3: Add a VPN connection that uses EAP authentication
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 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.
Example 4: Add a VPN connection that uses a custom EAP authentication method
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.
Example 5: Add a VPN connection that uses already generated EAP XML configuration
This set of commands adds a VPN connection using an already generated EAP XML configuration. For more information about how to generate EAP XML configuration, see EAP Configuration.
Parameters
-AllUserConnection
Indicates that the cmdlet adds the VPN connection to the global phone book entries.
Parameter properties
Type:
SwitchParameter
Default value:
None
Supports wildcards:
False
DontShow:
False
Parameter sets
InboxProfile
Position:
7
Mandatory:
False
Value from pipeline:
False
Value from pipeline by property name:
True
Value from remaining arguments:
False
-AsJob
Runs the cmdlet as a background job. Use this parameter to run commands that take a long time to complete.
Parameter properties
Type:
SwitchParameter
Default value:
None
Supports wildcards:
False
DontShow:
False
Parameter sets
(All)
Position:
Named
Mandatory:
False
Value from pipeline:
False
Value from pipeline by property name:
False
Value from remaining arguments:
False
-AuthenticationMethod
Specifies the authentication method to use for the VPN connection.
Parameter properties
Type:
String[]
Default value:
None
Accepted values:
Pap, Chap, MSChapv2, Eap, MachineCertificate
Supports wildcards:
False
DontShow:
False
Parameter sets
InboxProfile
Position:
5
Mandatory:
False
Value from pipeline:
False
Value from pipeline by property name:
True
Value from remaining arguments:
False
-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.
Parameter properties
Type:
CimSession[]
Default value:
None
Supports wildcards:
False
DontShow:
False
Aliases:
Session
Parameter sets
(All)
Position:
Named
Mandatory:
False
Value from pipeline:
False
Value from pipeline by property name:
False
Value from remaining arguments:
False
-Confirm
Prompts you for confirmation before running the cmdlet.
Parameter properties
Type:
SwitchParameter
Default value:
False
Supports wildcards:
False
DontShow:
False
Aliases:
cf
Parameter sets
(All)
Position:
Named
Mandatory:
False
Value from pipeline:
False
Value from pipeline by property name:
False
Value from remaining arguments:
False
-CustomConfiguration
Specifies an XML document that allows vendors to specify custom configuration information.
Parameter properties
Type:
XmlDocument
Default value:
None
Supports wildcards:
False
DontShow:
False
Parameter sets
ThirdParty
Position:
Named
Mandatory:
True
Value from pipeline:
False
Value from pipeline by property name:
True
Value from remaining arguments:
False
-DnsSuffix
Specifies the DNS suffix of the VPN connection.
Parameter properties
Type:
String
Default value:
None
Supports wildcards:
False
DontShow:
False
Parameter sets
(All)
Position:
Named
Mandatory:
False
Value from pipeline:
False
Value from pipeline by property name:
True
Value from remaining arguments:
False
-EapConfigXmlStream
Specifies the contents of the EAP XML configuration file, which includes the EAP method ID.
Parameter properties
Type:
XmlDocument
Default value:
None
Supports wildcards:
False
DontShow:
False
Parameter sets
InboxProfile
Position:
11
Mandatory:
False
Value from pipeline:
False
Value from pipeline by property name:
True
Value from remaining arguments:
False
-EncryptionLevel
Specifies the encryption level for the VPN connection.
Parameter properties
Type:
String
Default value:
None
Accepted values:
NoEncryption, Optional, Required, Maximum, Custom
Supports wildcards:
False
DontShow:
False
Parameter sets
InboxProfile
Position:
4
Mandatory:
False
Value from pipeline:
False
Value from pipeline by property name:
True
Value from remaining arguments:
False
-Force
Indicates that the pre-shared key (PSK) value is supplied over an insecure channel, if L2TP is used.
Parameter properties
Type:
SwitchParameter
Default value:
None
Supports wildcards:
False
DontShow:
False
Parameter sets
(All)
Position:
Named
Mandatory:
False
Value from pipeline:
False
Value from pipeline by property name:
False
Value from remaining arguments:
False
-IdleDisconnectSeconds
Specifies the time, in seconds, before an idle connection is closed.
Parameter properties
Type:
UInt32
Default value:
None
Supports wildcards:
False
DontShow:
False
Parameter sets
(All)
Position:
Named
Mandatory:
False
Value from pipeline:
False
Value from pipeline by property name:
True
Value from remaining arguments:
False
-L2tpPsk
Specifies the value of the PSK to be used for L2TP authentication.
If this parameter is not specified, a certificate is used for L2TP.
Parameter properties
Type:
String
Default value:
None
Supports wildcards:
False
DontShow:
False
Parameter sets
InboxProfile
Position:
8
Mandatory:
False
Value from pipeline:
False
Value from pipeline by property name:
True
Value from remaining arguments:
False
-MachineCertificateEKUFilter
Specifies an array of enhanced key usage (EKU) filters for Internet Key Exchange version 2 (IKEv2) machine certificate selection.
Parameter properties
Type:
String[]
Default value:
None
Supports wildcards:
False
DontShow:
False
Parameter sets
InboxProfile
Position:
Named
Mandatory:
False
Value from pipeline:
False
Value from pipeline by property name:
True
Value from remaining arguments:
False
-MachineCertificateIssuerFilter
Specifies the X509 certificate of the issuer filter for IKEv2 machine certificate selection.
Parameter properties
Type:
X509Certificate2
Default value:
None
Supports wildcards:
False
DontShow:
False
Parameter sets
InboxProfile
Position:
Named
Mandatory:
False
Value from pipeline:
False
Value from pipeline by property name:
True
Value from remaining arguments:
False
-Name
Specifies the name of this VPN connection profile.
Parameter properties
Type:
String
Default value:
None
Supports wildcards:
False
DontShow:
False
Aliases:
ConnectionName
Parameter sets
(All)
Position:
1
Mandatory:
True
Value from pipeline:
False
Value from pipeline by property name:
True
Value from remaining arguments:
False
-PassThru
Returns an object representing the item with which you are working.
By default, this cmdlet does not generate any output.
Parameter properties
Type:
SwitchParameter
Default value:
None
Supports wildcards:
False
DontShow:
False
Parameter sets
(All)
Position:
Named
Mandatory:
False
Value from pipeline:
False
Value from pipeline by property name:
False
Value from remaining arguments:
False
-PlugInApplicationID
Specifies the identifier for a third party application.
Parameter properties
Type:
String
Default value:
None
Supports wildcards:
False
DontShow:
False
Parameter sets
ThirdParty
Position:
10
Mandatory:
True
Value from pipeline:
False
Value from pipeline by property name:
True
Value from remaining arguments:
False
-RememberCredential
Indicates that the credentials supplied at the time of first successful connection are stored in the cache.
Parameter properties
Type:
SwitchParameter
Default value:
None
Supports wildcards:
False
DontShow:
False
Parameter sets
(All)
Position:
9
Mandatory:
False
Value from pipeline:
False
Value from pipeline by property name:
True
Value from remaining arguments:
False
-ServerAddress
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.
Parameter properties
Type:
String
Default value:
None
Supports wildcards:
False
DontShow:
False
Aliases:
ServerName, DefaultServer
Parameter sets
(All)
Position:
2
Mandatory:
True
Value from pipeline:
False
Value from pipeline by property name:
True
Value from remaining arguments:
False
-ServerList
Specifies an array of VPN servers.
The VPN client can connect to these servers.
Parameter properties
Type:
CimInstance[]
Default value:
None
Supports wildcards:
False
DontShow:
False
Parameter sets
(All)
Position:
Named
Mandatory:
False
Value from pipeline:
False
Value from pipeline by property name:
True
Value from remaining arguments:
False
-SplitTunneling
Indicates that the cmdlet enables split tunneling for this VPN connection profile.
When you enable split tunneling, traffic to destinations outside the intranet does not flow through the VPN tunnel.
If you do not specify this parameter, split tunneling is disabled.
Parameter properties
Type:
SwitchParameter
Default value:
None
Supports wildcards:
False
DontShow:
False
Parameter sets
(All)
Position:
6
Mandatory:
False
Value from pipeline:
False
Value from pipeline by property name:
True
Value from remaining arguments:
False
-ThrottleLimit
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.
Parameter properties
Type:
Int32
Default value:
None
Supports wildcards:
False
DontShow:
False
Parameter sets
(All)
Position:
Named
Mandatory:
False
Value from pipeline:
False
Value from pipeline by property name:
False
Value from remaining arguments:
False
-TunnelType
Specifies the type of tunnel used for the VPN connection.
Parameter properties
Type:
String
Default value:
None
Accepted values:
Pptp, L2tp, Sstp, Ikev2, Automatic
Supports wildcards:
False
DontShow:
False
Parameter sets
InboxProfile
Position:
3
Mandatory:
False
Value from pipeline:
False
Value from pipeline by property name:
True
Value from remaining arguments:
False
-UseWinlogonCredential
Indicates that MSCHAPv2 or EAP MSCHAPv2 is used as the authentication method, and that Windows logon credentials are used automatically when connecting with this VPN connection profile.
Parameter properties
Type:
SwitchParameter
Default value:
None
Supports wildcards:
False
DontShow:
False
Parameter sets
InboxProfile
Position:
10
Mandatory:
False
Value from pipeline:
False
Value from pipeline by property name:
True
Value from remaining arguments:
False
-WhatIf
Shows what would happen if the cmdlet runs.
The cmdlet is not run.
Parameter properties
Type:
SwitchParameter
Default value:
False
Supports wildcards:
False
DontShow:
False
Aliases:
wi
Parameter sets
(All)
Position:
Named
Mandatory:
False
Value from pipeline:
False
Value from pipeline by property name:
False
Value from remaining arguments:
False
CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable,
-InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable,
-ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see
about_CommonParameters.
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.
This cmdlet returns a VpnConnection object that contains the VPN connection configuration settings.