mirror of
https://github.com/fleschutz/PowerShell.git
synced 2024-11-29 19:33:20 +01:00
Update check-vpn.ps1
This commit is contained in:
parent
345da64609
commit
f8159e0769
@ -2,10 +2,10 @@
|
|||||||
.SYNOPSIS
|
.SYNOPSIS
|
||||||
Checks the VPN status
|
Checks the VPN status
|
||||||
.DESCRIPTION
|
.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
|
.EXAMPLE
|
||||||
PS> ./check-vpn.ps1
|
PS> ./check-vpn.ps1
|
||||||
✅ VPN to NASA L2TP is disconnected
|
✅ VPN disconnected to NASA L2TP
|
||||||
.LINK
|
.LINK
|
||||||
https://github.com/fleschutz/PowerShell
|
https://github.com/fleschutz/PowerShell
|
||||||
.NOTES
|
.NOTES
|
||||||
@ -13,17 +13,17 @@
|
|||||||
#>
|
#>
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$NoVPN = $true
|
$noVPN = $true
|
||||||
if ($IsLinux) {
|
if ($IsLinux) {
|
||||||
# TODO
|
# TODO
|
||||||
} else {
|
} else {
|
||||||
$Connections = Get-VPNConnection
|
$Connections = Get-VPNConnection
|
||||||
foreach($Connection in $Connections) {
|
foreach($Connection in $Connections) {
|
||||||
Write-Host "✅ VPN to $($Connection.Name) is $($Connection.ConnectionStatus.ToLower())"
|
Write-Host "✅ VPN $($Connection.ConnectionStatus.ToLower()) to $($Connection.Name)"
|
||||||
$NoVPN = $false
|
$noVPN = $false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($NoVPN) { Write-Host "⚠️ No VPN configured" }
|
if ($noVPN) { Write-Host "⚠️ No VPN configured" }
|
||||||
exit 0 # success
|
exit 0 # success
|
||||||
} catch {
|
} catch {
|
||||||
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||||
|
Loading…
Reference in New Issue
Block a user