Update check-vpn.ps1

This commit is contained in:
Markus Fleschutz 2023-04-17 21:38:20 +02:00
parent 9b8bd116e6
commit 515369b938

View File

@ -5,7 +5,7 @@
This PowerShell script queries the status of the VPN connections and prints it. This PowerShell script queries the status of the VPN connections and prints it.
.EXAMPLE .EXAMPLE
PS> ./check-vpn PS> ./check-vpn
VPN 'NASA L2TP' is Disconnected Disconnected VPN 'NASA L2TP'
.LINK .LINK
https://github.com/fleschutz/PowerShell https://github.com/fleschutz/PowerShell
.NOTES .NOTES
@ -19,11 +19,11 @@ try {
} else { } else {
$Connections = Get-VPNConnection $Connections = Get-VPNConnection
foreach($Connection in $Connections) { foreach($Connection in $Connections) {
Write-Host "✅ VPN '$($Connection.Name)' is $($Connection.ConnectionStatus)" "$($Connection.ConnectionStatus) VPN '$($Connection.Name)'"
$NoVPN = $false $NoVPN = $false
} }
} }
if ($NoVPN) { Write-Host "⚠️ No VPN connection" } if ($NoVPN) { "⚠️ No VPN" }
exit 0 # success exit 0 # success
} catch { } catch {
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])" "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"