PowerShell/Scripts/check-vpn.ps1

29 lines
729 B
PowerShell
Raw Normal View History

2021-12-02 14:49:17 +01:00
<#
.SYNOPSIS
2021-12-03 10:12:56 +01:00
Checks the VPN connections
2021-12-02 14:49:17 +01:00
.DESCRIPTION
2021-12-03 10:12:56 +01:00
This script checks all available VPN connections.
2021-12-02 14:49:17 +01:00
.EXAMPLE
PS> ./check-vpn
.LINK
https://github.com/fleschutz/PowerShell
.NOTES
Author: Markus Fleschutz · License: CC0
#>
try {
$Connections = (Get-VPNConnection)
$Reply = ""
foreach($Connection in $Connections) {
2021-12-03 10:12:56 +01:00
if ("$Reply" -eq "") { $Reply += "VPN connection " } else { $Reply += ", " }
$Reply += "$($Connection.Name) is $($Connection.ConnectionStatus)"
2021-12-02 14:49:17 +01:00
}
2021-12-02 14:52:25 +01:00
if ("$Reply" -eq "") { $Reply = "No VPN connection available" }
2021-12-02 14:49:17 +01:00
2021-12-06 17:00:49 +01:00
& "$PSScriptRoot/give-reply.ps1" "$Reply"
2021-12-02 14:49:17 +01:00
exit 0 # success
} catch {
"⚠️ Error: $($Error[0]) ($($MyInvocation.MyCommand.Name):$($_.InvocationInfo.ScriptLineNumber))"
exit 1
}