Update check-vpn.ps1

This commit is contained in:
Markus Fleschutz 2022-10-25 14:58:55 +02:00
parent 767634fba0
commit 7b6f2b7cc2

View File

@ -1,6 +1,6 @@
<# <#
.SYNOPSIS .SYNOPSIS
Checks the VPN connection(s) Checks the VPN connection
.DESCRIPTION .DESCRIPTION
This PowerShell script queries and prints the status of any VPN connection. This PowerShell script queries and prints the status of any VPN connection.
.EXAMPLE .EXAMPLE
@ -12,17 +12,17 @@
#> #>
try { try {
$FoundOne = $false $NoVPN = $true
if ($IsLinux) { if ($IsLinux) {
# TODO # TODO
} else { } else {
$Connections = (Get-VPNConnection) $Connections = (Get-VPNConnection)
foreach($Connection in $Connections) { foreach($Connection in $Connections) {
"✅ VPN $($Connection.Name) is $($Connection.ConnectionStatus)." "✅ VPN '$($Connection.Name)' is $($Connection.ConnectionStatus)."
$FoundOne = $true $NoVPN = $false
} }
} }
if (!$FoundOne) { "⚠️ No VPN connection." } if ($NoVPN) { "⚠️ No VPN connection." }
exit 0 # success exit 0 # success
} catch { } catch {
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"