2021-12-02 14:49:17 +01:00
|
|
|
|
<#
|
|
|
|
|
.SYNOPSIS
|
2022-10-25 14:58:55 +02:00
|
|
|
|
Checks the VPN connection
|
2021-12-02 14:49:17 +01:00
|
|
|
|
.DESCRIPTION
|
2022-10-11 20:00:39 +02:00
|
|
|
|
This PowerShell script queries and prints the status of any VPN connection.
|
2021-12-02 14:49:17 +01:00
|
|
|
|
.EXAMPLE
|
|
|
|
|
PS> ./check-vpn
|
|
|
|
|
.LINK
|
|
|
|
|
https://github.com/fleschutz/PowerShell
|
|
|
|
|
.NOTES
|
2022-05-10 07:33:18 +02:00
|
|
|
|
Author: Markus Fleschutz | License: CC0
|
2021-12-02 14:49:17 +01:00
|
|
|
|
#>
|
|
|
|
|
|
|
|
|
|
try {
|
2022-10-25 14:58:55 +02:00
|
|
|
|
$NoVPN = $true
|
2022-10-11 20:00:39 +02:00
|
|
|
|
if ($IsLinux) {
|
|
|
|
|
# TODO
|
|
|
|
|
} else {
|
|
|
|
|
$Connections = (Get-VPNConnection)
|
|
|
|
|
foreach($Connection in $Connections) {
|
2022-10-25 14:58:55 +02:00
|
|
|
|
"✅ VPN '$($Connection.Name)' is $($Connection.ConnectionStatus)."
|
|
|
|
|
$NoVPN = $false
|
2022-10-11 20:00:39 +02:00
|
|
|
|
}
|
2021-12-02 14:49:17 +01:00
|
|
|
|
}
|
2022-10-25 14:58:55 +02:00
|
|
|
|
if ($NoVPN) { "⚠️ No VPN connection." }
|
2022-04-13 12:06:32 +02:00
|
|
|
|
exit 0 # success
|
2021-12-02 14:49:17 +01:00
|
|
|
|
} catch {
|
2022-05-10 07:33:18 +02:00
|
|
|
|
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
2021-12-02 14:49:17 +01:00
|
|
|
|
exit 1
|
2022-10-11 20:00:39 +02:00
|
|
|
|
}
|