With Windows 10’s PowerShell cmdlet, you can easily add applications to automatically trigger a VPN connection when they launch. Automating this task means you won’t even have to think about connecting to a VPN when you use certain apps.

To take advantage of this functionality in PowerShell, you’ll first have to add a VPN service to your computer if you don’t already have one.

RELATED: How to Connect to a VPN in Windows

How to Add VPN Auto-Triggering

After you set up a VPN connection on Windows 10, you’ll need to open an elevated instance of PowerShell. To do so, click the Start button, and then type “Powershell.” Right-click “Windows PowerShell,” and then select “Run as Administrator” from the menu.

Click “Yes” in the prompt that appears to allow access to your computer.

In the PowerShell window, type the following and replace  and with the name of the VPN connection, and the file path to the application you want to use, respectively:

Make sure you include the quotation marks in the command.

Press Enter to run the command. PowerShell warns you that split tunneling is disabled by default. To continue, you must confirm and enable the feature before it’s automatically triggered.

Type “Y” when the prompt appears, and then press Enter once more to finish.

You have to enable split tunneling for the auto-trigger to connect to the VPN without human intervention.

Split tunneling stops Windows from routing all network traffic through the VPN when the application triggers it to start. Instead, it splits the traffic, and only the data from the application listed will flow through the VPN.

Type Set-VpnConnection -Name “” -SplitTunneling $True into PowerShell and replace  with the name of your VPN (again, keep the quotes around it), and then press Enter.

Next, in case you accidentally close the application and don’t want the connection to terminate, you can set a timeout buffer for you to restart the app.

Type Set-VpnConnection -Name “” -IdleDisconnectSeconds into PowerShell and press Enter. Replace with the name of your connection and with the number of seconds to wait until the connection terminates.

Now, when the application closes, Windows will wait 10 seconds before it terminates the VPN connection. You can make this number whatever you want or omit this step altogether.

How to See Which Applications Auto-Trigger a VPN

There are a few ways you can check to see which applications you’ve set to trigger the start of a VPN connection. You can either use a cmdlet inside PowerShell or edit the phonebook file in File Explorer.

RELATED: How PowerShell Differs From the Windows Command Prompt

If the VPN suddenly starts and you’re unsure why, you can use either of the following methods to pinpoint which application triggered it.

Using a PowerShell Cmdlet

To use this method, click the Start button and type “Powershell.” Right-click “Windows PowerShell,” and then select “Run as Administrator” from the menu.

Click “Yes” in the prompt that appears to allow access to your computer.

In the PowerShell window, type the following command, but replace  with the name of your VPN connection, and then press Enter:

In our example, the command retrieved the trigger properties of the VPN connection “VPN Canada” and displayed them below.

Using File Explorer

The other option is to track down the dial-up phonebook file in File Explorer. You can open it in a text editor and see the list of applications that trigger the VPN.

A phonebook file provides a standard way for Windows to collect and specify the information it needs to establish a Remote Access Connection (RAS). The file contains information like IP addresses, ports, modem settings, and—the info we’re looking for—applications that trigger the connection.

To get started, open File Explorer and paste the following directory into the address bar, but replace  with the current username, and then press Enter:

Right-click “rasphone.pbk,” and then select the text editor in which you want to open the file.

This one file contains all the VPN connections on your computer, so if you have more than one VPN, you might have to sift through a lot to find the applications you want. Each application is stored under the function “ClassicApplicationIDs” as its direct file path.

Luckily, if you don’t want to scroll to find each app, most text editors have a Find feature. Press Ctrl+F, type “ClassicApplicationIds” in the text field, and then press Enter.

How to Remove VPN Auto-Triggering

If you accidentally add the wrong application or no longer want the VPN to trigger when you launch specific apps, you can remove them using a similar cmdlet in PowerShell.

RELATED: Geek School: Learning to Use Cmdlets in PowerShell

To remove VPN auto-triggering, click the Start button, and then type “Powershell.” Right-click “Windows PowerShell,” and then select “Run as Administrator” from the menu.

Click “Yes” in the prompt that appears to allow access to your computer.

In the PowerShell window, type the following, but replace  and  with the name of your VPN connection and the path to the application, respectively:

PowerShell prompts you to confirm you want to remove the application from the auto-trigger list. Type “Y” and press Enter.

Repeat this step for every application you want to remove from the list.

Now, when you launch the applications you specified, Windows will initiate a VPN connection and send their traffic through it—no third-party software required.