Add check-vpn.ps1

This commit is contained in:
Markus Fleschutz 2021-12-02 14:49:17 +01:00
parent 3796e65120
commit b3e6c4711f
2 changed files with 29 additions and 1 deletions

View File

@ -97,7 +97,7 @@ Computer, open `name` settings
Computer, check `name`
----------------------
* let the computer check something.
* replace `name` by: "CPU", "date", "DNS", "Earth", "operating system", "ping", "swap space", "time", "time zone", "up-time", or "weather".
* replace `name` by: "CPU", "date", "DNS", "Earth", "operating system", "ping", "swap space", "time", "time zone", "up-time", "VPN", or "weather".
🔊 Audio

28
Scripts/check-vpn.ps1 Executable file
View File

@ -0,0 +1,28 @@
<#
.SYNOPSIS
Checks the VPN connection(s)
.DESCRIPTION
This script checks the VPN connection(s).
.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) {
$Reply += "connection $($Connection.Name) is $($Connection.ConnectionStatus), "
}
if ("$Reply" -eq "") { $Reply = "No VPN connection available"
"✔️ $Reply"
& "$PSScriptRoot/speak-english.ps1" "$Reply"
exit 0 # success
} catch {
"⚠️ Error: $($Error[0]) ($($MyInvocation.MyCommand.Name):$($_.InvocationInfo.ScriptLineNumber))"
exit 1
}