-
Notifications
You must be signed in to change notification settings - Fork 15
/
Detect-DeviceVpnConnection.ps1
69 lines (44 loc) · 1.45 KB
/
Detect-DeviceVpnConnection.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<#
.SYNOPSIS
PowerShell script to detect an existing VPN device connection.
.EXAMPLE
.\Detect-DeviceVpnConnection.ps1
.DESCRIPTION
This PowerShell script is deployed as a detection script using Microsoft Intune remediations.
.LINK
https://github.com/richardhicks/endpointmanager/blob/main/Detect-DeviceVpnConnection.ps1
.LINK
https://learn.microsoft.com/en-us/mem/intune/fundamentals/remediations
.LINK
https://directaccess.richardhicks.com/2021/12/06/always-on-vpn-and-intune-proactive-remediation/
.LINK
https://directaccess.richardhicks.com/
.NOTES
Version: 1.0
Creation Date: September 26, 2023
Last Updated: September 26, 2023
Author: Richard Hicks
Organization: Richard M. Hicks Consulting, Inc.
Contact: rich@richardhicks.com
Website: https://www.richardhicks.com/
#>
[CmdletBinding()]
Param (
)
$ConnectionName = 'Always On VPN Device Tunnel'
$Vpn = Get-VPnConnection -Name $ConnectionName -AllUserConnection -ErrorAction SilentlyContinue
Try {
If ($Null -eq $Vpn) {
Write-Warning "VPN connection `'$ConnectionName`' not found."
Exit 0
}
Else {
Write-Verbose "VPN connection name matching `'$ConnectionName`' found. Remediation required."
Exit 1
}
}
Catch {
$ErrorMessage = $_.Exception.Message
Write-Warning $ErrorMessage
Exit 1
}