- Set-Vpn Connection
- Syntax
- Description
- Examples
- Example 1: Configure a single VPN connection
- Example 2: Configure a VPN connection with several settings
- Example 3: Configure a VPN connection to use a custom EAP configuration
- Parameters
- Outputs
- Add-Vpn Connection
- Syntax
- Description
- Examples
- Example 1: Add a VPN connection
- Example 2: Add a VPN connection with an alternate authentication method
- Example 3: Add a VPN connection that uses EAP authentication
- Example 4: Add a VPN connection that uses a custom EAP authentication method
- Example 5: Add a VPN connection that uses already generated EAP XML configuration
- Parameters
- Outputs
Set-Vpn Connection
Changes the configuration settings of an existing VPN connection profile.
Syntax
Description
The Set-VpnConnection cmdlet changes the configuration settings of an existing VPN connection profile. If the VPN profile specified does not exist, you see an error. If errors occur when you modify the VPN profile, the cmdlet returns the error information.
Examples
Example 1: Configure a single VPN connection
This command configures the VPN connection named Test1 to connect to the server with an IP address of 10.1.1.2. By specifying the PassThru parameter, you can see the configuration of the VPN connection object.
Example 2: Configure a VPN connection with several settings
This command configures the VPN connection named Test3 and located in the global phone book as follows:
- The connection is configured to use L2tp as the tunnel type, as specified by the TunnelType parameter
- The tunnel is using optional encryption, as specified by the EncryptionLevel parameter
- The authentication method used by the connection is PAP, as specified by the AuthenticationMethod parameter
- Split tunneling is turned off, as specified by the SplitTunneling parameter, and the value of $False
- Credential caching is turned off, as specified by the RememberCredential parameter and the value of $False
By specifying the PassThru parameter, you can see the configuration of the VPN connection object.
Example 3: Configure a VPN connection to use a custom EAP configuration
This set of commands first creates a custom EAP configuration, and then configures a VPN connection from the global phone book to use the new custom EAP configuration.
For more information about custom EAP creation, see the New-EapConfiguration cmdlet.
Parameters
Indicates that the VPN connection specified is in the global phone book.
Type: | SwitchParameter |
Position: | 7 |
Default value: | None |
Accept pipeline input: | True |
Accept wildcard characters: | False |
Runs the cmdlet as a background job. Use this parameter to run commands that take a long time to complete.
Type: | SwitchParameter |
Position: | Named |
Default value: | None |
Accept pipeline input: | False |
Accept wildcard characters: | False |
Specifies the authentication method to use for the VPN connection. The acceptable values for this parameter are:
- PAP
- CHAP
- MSCHAPv2
- EAP
Type: | String [ ] |
Accepted values: | Pap, Chap, MSChapv2, Eap, MachineCertificate |
Position: | 5 |
Default value: | None |
Accept pipeline input: | True |
Accept wildcard characters: | False |
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.
Type: | CimSession [ ] |
Aliases: | Session |
Position: | Named |
Default value: | None |
Accept pipeline input: | False |
Accept wildcard characters: | False |
Prompts you for confirmation before running the cmdlet.
Type: | SwitchParameter |
Aliases: | cf |
Position: | Named |
Default value: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
Specifies an XML document that allows vendors to specify custom configuration information.
Type: | XmlDocument |
Position: | Named |
Default value: | None |
Accept pipeline input: | True |
Accept wildcard characters: | False |
Specifies the DNS suffix of the VPN connection.
Type: | String |
Position: | Named |
Default value: | None |
Accept pipeline input: | True |
Accept wildcard characters: | False |
Specifies the contents of the EAP XML configuration file, which includes the EAP method ID.
Type: | XmlDocument |
Position: | 11 |
Default value: | None |
Accept pipeline input: | True |
Accept wildcard characters: | False |
Specifies the encryption level for the VPN connection. The acceptable values for this parameter are:
- NoEncryption
- Optional
- Required
- Maximum
Type: | String |
Accepted values: | NoEncryption, Optional, Required, Maximum, Custom |
Position: | 4 |
Default value: | None |
Accept pipeline input: | True |
Accept wildcard characters: | False |
Indicates that the pre-shared key (PSK) value is supplied over an insecure channel, if L2TP is used.
Type: | SwitchParameter |
Position: | Named |
Default value: | None |
Accept pipeline input: | False |
Accept wildcard characters: | False |
Specifies the time, in seconds, before closing an idle connection.
Type: | UInt32 |
Position: | Named |
Default value: | None |
Accept pipeline input: | True |
Accept wildcard characters: | False |
Specifies the value of the PSK to be used for L2TP authentication. If this parameter is not specified, a certificate is used for L2TP.
Type: | String |
Position: | 8 |
Default value: | None |
Accept pipeline input: | True |
Accept wildcard characters: | False |
Specifies an array of enhanced key usage (EKU) filters for Internet Key Exchange version 2 (IKEv2) machine certificate selection.
Type: | String [ ] |
Position: | Named |
Default value: | None |
Accept pipeline input: | True |
Accept wildcard characters: | False |
Specifies the X509 certificate of the issuer filter for IKEv2 machine certificate selection.
Type: | X509Certificate2 |
Position: | Named |
Default value: | None |
Accept pipeline input: | True |
Accept wildcard characters: | False |
Specifies the name of the VPN connection profile.
Type: | String |
Aliases: | ConnectionName |
Position: | 1 |
Default value: | None |
Accept pipeline input: | True |
Accept wildcard characters: | False |
Returns an object representing the item with which you are working. By default, this cmdlet does not generate any output.
Type: | SwitchParameter |
Position: | Named |
Default value: | None |
Accept pipeline input: | False |
Accept wildcard characters: | False |
Specifies the identifier for a third party application.
Type: | String |
Position: | 10 |
Default value: | None |
Accept pipeline input: | True |
Accept wildcard characters: | False |
Indicates that the credentials supplied at the time of first successful connection is stored in the cache, if set to $True.
Type: | Boolean |
Position: | 9 |
Default value: | None |
Accept pipeline input: | True |
Accept wildcard characters: | False |
Specifies the address of the remote VPN server to which the client connects. You can specify the address as a fully qualified domain name (FQDN), an IPv4 address, or an IPv6 address.
Type: | String |
Aliases: | ServerName, DefaultServer |
Position: | 2 |
Default value: | None |
Accept pipeline input: | True |
Accept wildcard characters: | False |
Specifies an array of VPN servers. The VPN client can connect to these servers.
Type: | CimInstance [ ] |
Position: | Named |
Default value: | None |
Accept pipeline input: | True |
Accept wildcard characters: | False |
Indicates whether the cmdlet enables split tunneling for the VPN connection profile. When you enable split tunneling, traffic to destinations outside the intranet does not flow through the VPN tunnel. Specify a value of $True to enable split tunneling.
Type: | Boolean |
Position: | 6 |
Default value: | None |
Accept pipeline input: | True |
Accept wildcard characters: | False |
Indicates that the cmdlet runs for a third party profile.
Type: | SwitchParameter |
Position: | 3 |
Default value: | None |
Accept pipeline input: | False |
Accept wildcard characters: | False |
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.
Type: | Int32 |
Position: | Named |
Default value: | None |
Accept pipeline input: | False |
Accept wildcard characters: | False |
Specifies the type of tunnel used for the VPN connection. The acceptable values for this parameter are:
- PPTP
- L2TP
- SSTP
- IKEv2
- Automatic
Type: | String |
Accepted values: | Pptp, L2tp, Sstp, Ikev2, Automatic |
Position: | 3 |
Default value: | None |
Accept pipeline input: | True |
Accept wildcard characters: | False |
Indicates whether to use Windows logon credentials. Specify a value of $True to use MSCHAPv2 or EAP-MSCHAPv2 as the authentication method and use Windows logon credentials automatically when connecting with the VPN connection profile.
Type: | Boolean |
Position: | 10 |
Default value: | None |
Accept pipeline input: | True |
Accept wildcard characters: | False |
Shows what would happen if the cmdlet runs. The cmdlet is not run.
Type: | SwitchParameter |
Aliases: | wi |
Position: | Named |
Default value: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
Outputs
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.
Add-Vpn Connection
Adds a VPN connection to the Connection Manager phone book.
Syntax
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 cmdlet returns the error information.
Examples
Example 1: 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.
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
Indicates that the cmdlet adds the VPN connection to the global phone book entries.
Type: | SwitchParameter |
Position: | 7 |
Default value: | None |
Accept pipeline input: | True |
Accept wildcard characters: | False |
Runs the cmdlet as a background job. Use this parameter to run commands that take a long time to complete.
Type: | SwitchParameter |
Position: | Named |
Default value: | None |
Accept pipeline input: | False |
Accept wildcard characters: | False |
Specifies the authentication method to use for the VPN connection.
Type: | String [ ] |
Accepted values: | Pap, Chap, MSChapv2, Eap, MachineCertificate |
Position: | 5 |
Default value: | None |
Accept pipeline input: | True |
Accept wildcard characters: | False |
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.
Type: | CimSession [ ] |
Aliases: | Session |
Position: | Named |
Default value: | None |
Accept pipeline input: | False |
Accept wildcard characters: | False |
Prompts you for confirmation before running the cmdlet.
Type: | SwitchParameter |
Aliases: | cf |
Position: | Named |
Default value: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
Specifies an XML document that allows vendors to specify custom configuration information.
Type: | XmlDocument |
Position: | Named |
Default value: | None |
Accept pipeline input: | True |
Accept wildcard characters: | False |
Specifies the DNS suffix of the VPN connection.
Type: | String |
Position: | Named |
Default value: | None |
Accept pipeline input: | True |
Accept wildcard characters: | False |
Specifies the contents of the EAP XML configuration file, which includes the EAP method ID.
Type: | XmlDocument |
Position: | 11 |
Default value: | None |
Accept pipeline input: | True |
Accept wildcard characters: | False |
Specifies the encryption level for the VPN connection.
Type: | String |
Accepted values: | NoEncryption, Optional, Required, Maximum, Custom |
Position: | 4 |
Default value: | None |
Accept pipeline input: | True |
Accept wildcard characters: | False |
Indicates that the pre-shared key (PSK) value is supplied over an insecure channel, if L2TP is used.
Type: | SwitchParameter |
Position: | Named |
Default value: | None |
Accept pipeline input: | False |
Accept wildcard characters: | False |
Specifies the time, in seconds, before an idle connection is closed.
Type: | UInt32 |
Position: | Named |
Default value: | None |
Accept pipeline input: | True |
Accept wildcard characters: | False |
Specifies the value of the PSK to be used for L2TP authentication. If this parameter is not specified, a certificate is used for L2TP.
Type: | String |
Position: | 8 |
Default value: | None |
Accept pipeline input: | True |
Accept wildcard characters: | False |
Specifies an array of enhanced key usage (EKU) filters for Internet Key Exchange version 2 (IKEv2) machine certificate selection.
Type: | String [ ] |
Position: | Named |
Default value: | None |
Accept pipeline input: | True |
Accept wildcard characters: | False |
Specifies the X509 certificate of the issuer filter for IKEv2 machine certificate selection.
Type: | X509Certificate2 |
Position: | Named |
Default value: | None |
Accept pipeline input: | True |
Accept wildcard characters: | False |
Specifies the name of this VPN connection profile.
Type: | String |
Aliases: | ConnectionName |
Position: | 1 |
Default value: | None |
Accept pipeline input: | True |
Accept wildcard characters: | False |
Returns an object representing the item with which you are working. By default, this cmdlet does not generate any output.
Type: | SwitchParameter |
Position: | Named |
Default value: | None |
Accept pipeline input: | False |
Accept wildcard characters: | False |
Specifies the identifier for a third party application.
Type: | String |
Position: | 10 |
Default value: | None |
Accept pipeline input: | True |
Accept wildcard characters: | False |
Indicates that the credentials supplied at the time of first successful connection are stored in the cache.
Type: | SwitchParameter |
Position: | 9 |
Default value: | None |
Accept pipeline input: | True |
Accept wildcard characters: | False |
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.
Type: | String |
Aliases: | ServerName, DefaultServer |
Position: | 2 |
Default value: | None |
Accept pipeline input: | True |
Accept wildcard characters: | False |
Specifies an array of VPN servers. The VPN client can connect to these servers.
Type: | CimInstance [ ] |
Position: | Named |
Default value: | None |
Accept pipeline input: | True |
Accept wildcard characters: | False |
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.
Type: | SwitchParameter |
Position: | 6 |
Default value: | None |
Accept pipeline input: | True |
Accept wildcard characters: | False |
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.
Type: | Int32 |
Position: | Named |
Default value: | None |
Accept pipeline input: | False |
Accept wildcard characters: | False |
Specifies the type of tunnel used for the VPN connection.
Type: | String |
Accepted values: | Pptp, L2tp, Sstp, Ikev2, Automatic |
Position: | 3 |
Default value: | None |
Accept pipeline input: | True |
Accept wildcard characters: | False |
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.
Type: | SwitchParameter |
Position: | 10 |
Default value: | None |
Accept pipeline input: | True |
Accept wildcard characters: | False |
Shows what would happen if the cmdlet runs. The cmdlet is not run.
Type: | SwitchParameter |
Aliases: | wi |
Position: | Named |
Default value: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
Outputs
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.