Update check-vpn.ps1

This commit is contained in:
Markus Fleschutz 2022-10-11 20:00:39 +02:00
parent d23eebc023
commit 3ac262573a

View File

@ -1,8 +1,8 @@
<# <#
.SYNOPSIS .SYNOPSIS
Checks the VPN connections Checks the VPN connection(s)
.DESCRIPTION .DESCRIPTION
This PowerShell script checks the status of all available VPN connections. This PowerShell script queries and prints the status of any VPN connection.
.EXAMPLE .EXAMPLE
PS> ./check-vpn PS> ./check-vpn
.LINK .LINK
@ -13,12 +13,16 @@
try { try {
$FoundOne = $false $FoundOne = $false
$Connections = (Get-VPNConnection) if ($IsLinux) {
foreach($Connection in $Connections) { # TODO
"✅ VPN $($Connection.Name) is $($Connection.ConnectionStatus)." } else {
$FoundOne = $true $Connections = (Get-VPNConnection)
foreach($Connection in $Connections) {
"✅ VPN $($Connection.Name) is $($Connection.ConnectionStatus)."
$FoundOne = $true
}
} }
if (!$FoundOne) { "⚠️ No VPN connection configured" } if (!$FoundOne) { "⚠️ 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])"