Skip to content
Menu

VPN Client Ready

Checks the one VPN client you name: Windows VPN profiles and whether their server resolves, or that the vendor client's service is running. Read-only.

VPN client ready is free for members.

Enter your email to create your free account and get the file.

We'll email you the script and the weekly MSP Outpost email. Unsubscribe anytime. Privacy policy.

Already a member? Sign in.

Be the first to review VPN client ready. Tell other MSPs how it worked for you.

Write a Review

LanguagePowerShell
Runs onWindows 10, Windows 11, Windows Server 2016+; runs as SYSTEM
NeedsPowerShell 5.1; the VpnClient and DnsClient modules for BuiltIn
Read-onlyReads, changes nothing

What It Does

Run it as SYSTEM from your RMM with Client set to the VPN this PC uses. For BuiltIn it reads all-users Windows VPN profiles and reports connection status. It checks DNS for server names and accepts IP addresses without a lookup. RequireConnected also alerts on disconnected profiles. Profiles that belong to one user are not visible to SYSTEM.

For FortiClient, Cisco Secure Client, GlobalProtect and WireGuard it checks the client's Windows service. A service that is stopped or disabled is an alert. For WireGuard it checks every tunnel service, or only the tunnel in ProfileName, and a tunnel name that does not exist alerts and lists the tunnels that do. It cannot tell whether a third-party tunnel is connected, only that its client is ready.

When the client is missing or no matching built-in profile exists, the run is SKIPPED unless RequireInstalled is true, in which case it alerts. If the Windows VPN commands are missing, it is skipped regardless. It keeps no state.

Partly tested: the Windows built-in VPN and WireGuard were tested on Windows 11, including a real WireGuard tunnel stopped and disabled. FortiClient, Cisco Secure Client and GlobalProtect were tested only on a PC without them.

Before You Run It

  • Set Client to the VPN this PC uses: BuiltIn, FortiClient, CiscoSecureClient, GlobalProtect or WireGuard.
  • Built-in VPN profiles must be created for all users to be visible to an RMM running as SYSTEM.

Type and Risk

  • Type: Monitor. It checks one condition. It exits 1 when it finds the problem, so your RMM can alert on it, 0 when all is well, and 2 when it could not run.
  • Risk: Low. It reads and changes nothing.
  • Restart: It never restarts the machine.
  • Typical run: Under 30 seconds.
  • Example answer: "VPN profile Office VPN: NotConnected; server vpn.example.com resolves"
  • Partly tested before listing on Windows 11 with Windows PowerShell 5.1, run as SYSTEM, against its own test cases; some of the products it supports were not available to test. The help says which.

Inputs

Pass an input as an argument (-Name value), as an environment variable with the same name, which is how most RMMs pass script variables, or change its default in the param() block at the top of the script. An argument wins over an environment variable, which wins over the default.

  • Client: BuiltIn (default), FortiClient, CiscoSecureClient, GlobalProtect or WireGuard.
  • ProfileName: BuiltIn: check only this profile name. WireGuard: check only this tunnel name. Empty (default) checks all. Ignored for the other clients.
  • RequireConnected: BuiltIn only. true alerts when a profile is not Connected. Default false.
  • RequireInstalled: true alerts when the client or the named profile is missing; false (default) is SKIPPED. A WireGuard ProfileName that matches no tunnel on a PC that has other tunnels always alerts (it names the tunnels there).

Every script also takes DryRun, OutputFormat (Text, Answer, Json or Csv), ExportPath and ResultField, which writes the answer to an RMM custom field.

License

Provided "as is" under the MIT License, without warranty of any kind. Test before production use. MSP Outpost and User First Digital Inc. accept no liability for any damage or loss.

The Script

test-vpn-client.ps1 · 848 lines · 45.6 KB

Free for Members

Create a free account or sign in to read, copy and download this script.

Welcome Back

Sign in to your MSP Outpost account.