Prerequisites:
- VPN used must be in the list of supported VPNs in the article below.
https://kb.policypak.com/kb/article/1066-04-which-vpn-solutions-are-currently-supported-for-use-with-scripts-manager-vpn-triggers/
-
Create a new policy (Set Launch Folder Windows in a Separate Process to Enabled) using Scripts & Triggers on the computer side, choose switched-mode like in the screenshot below.
-
At the “On apply action” screen select “PowerShell script” from the dropdown, then in the main text window, paste in the script below, check the option “Run script as user, then click “Next”.
-
Then click “Next” at the “On revert action” screen to skip that screen, then at the “Specify process mode” screen choose the “Once” option.
-
At the “Policy settings” screen give the policy a descriptive name then click “Finish.
-
Now create another policy (Map drives when VPN connects) using Scripts & Triggers on the computer side, choose switched-mode like in the screenshot below.
-
At the “On apply action” screen select “PowerShell script” from the dropdown, then in the main text window, paste in the script below then change the drive mappings to match the settings needed for your environment, check the option “Run script as user, then click “Next”.
-
Click “Next” at the “On revert action” screen to skip that screen, then at the “specify process mode” screen choose the “On trigger” option, then choose “VPN connect” from the drop down before clicking “Next” to continue.
-
At the “Trigger settings” screen enter an asterisk (wildcard, etc.) for the server name, then click “Next”.
-
At the “Policy settings” screen give the policy a descriptive name then click “Finish.
Note: You should have two policies now:
-
Lastly, test the policy by logging into a computer, (or run gpupdate if already logged in) and then connect to a VPN as a user that should receive the policy. If everything works you should see the network drives show up in File Explorer, you may need to click refresh if you had File Explorer already open to update the window contents.
-
Optionally, create a new Scripts and Triggers policy that disconnects the drives when the VPN disconnects by using the script below and also changing the trigger to “VPN disconnect”.
Note: “On trigger” does not work with Revert action script which is why you need to create a new policy to disconnect the drives.