Update check-vpn.ps1

This commit is contained in:
Markus Fleschutz 2023-08-21 22:06:58 +02:00
parent 345da64609
commit f8159e0769

View File

@ -2,10 +2,10 @@
.SYNOPSIS
Checks the VPN status
.DESCRIPTION
This PowerShell script queries and prints the status of the VPN connection(s).
This PowerShell script queries the status of the VPN connection(s) and prints it.
.EXAMPLE
PS> ./check-vpn.ps1
VPN to NASA L2TP is disconnected
VPN disconnected to NASA L2TP
.LINK
https://github.com/fleschutz/PowerShell
.NOTES
@ -13,17 +13,17 @@
#>
try {
$NoVPN = $true
$noVPN = $true
if ($IsLinux) {
# TODO
} else {
$Connections = Get-VPNConnection
foreach($Connection in $Connections) {
Write-Host "✅ VPN to $($Connection.Name) is $($Connection.ConnectionStatus.ToLower())"
$NoVPN = $false
Write-Host "✅ VPN $($Connection.ConnectionStatus.ToLower()) to $($Connection.Name)"
$noVPN = $false
}
}
if ($NoVPN) { Write-Host "⚠️ No VPN configured" }
if ($noVPN) { Write-Host "⚠️ No VPN configured" }
exit 0 # success
} catch {
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"