mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-02-22 12:41:24 +01:00
Update check-vpn.ps1
This commit is contained in:
parent
bbdac87cde
commit
3fa92d1935
@ -2,7 +2,7 @@
|
||||
.SYNOPSIS
|
||||
Checks the VPN connections
|
||||
.DESCRIPTION
|
||||
This script checks all available VPN connections.
|
||||
This script checks the status of all available VPN connections.
|
||||
.EXAMPLE
|
||||
PS> ./check-vpn
|
||||
.LINK
|
||||
@ -12,17 +12,15 @@
|
||||
#>
|
||||
|
||||
try {
|
||||
$FoundOne = $false
|
||||
$Connections = (Get-VPNConnection)
|
||||
$Reply = ""
|
||||
foreach($Connection in $Connections) {
|
||||
if ("$Reply" -eq "") { $Reply += "VPN connection " } else { $Reply += ", " }
|
||||
$Reply += "$($Connection.Name) is $($Connection.ConnectionStatus)"
|
||||
& "$PSScriptRoot/give-reply.ps1" "VPN $($Connection.Name) is $($Connection.ConnectionStatus)."
|
||||
$FoundOne = $true
|
||||
}
|
||||
if ("$Reply" -eq "") { $Reply = "No VPN connection available" }
|
||||
|
||||
& "$PSScriptRoot/give-reply.ps1" "$Reply"
|
||||
exit 0 # success
|
||||
if (!$FoundOne) { throw "No VPN connection available" }
|
||||
exit 0
|
||||
} catch {
|
||||
"⚠️ Error: $($Error[0]) ($($MyInvocation.MyCommand.Name):$($_.InvocationInfo.ScriptLineNumber))"
|
||||
& "$PSScriptRoot/give-reply.ps1" "Sorry: $($Error[0])."
|
||||
exit 1
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user