-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathRDPEnabled.ps1
34 lines (28 loc) · 1.67 KB
/
RDPEnabled.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
# Name: RDPEnabled.ps1
# Description: Script is designed to set custom attribute to show if RDP is enabled on the endpoint.
# Copyright (C) 2024 Action1 Corporation
# Documentation: https://github.com/Action1Corp/PSAction1/
# Use Action1 Roadmap system (https://roadmap.action1.com/) to submit feedback or enhancement requests.
# WARNING: Carefully study the provided scripts and components before using them. Test in your non-production lab first.
# LIMITATION OF LIABILITY. IN NO EVENT SHALL ACTION1 OR ITS SUPPLIERS, OR THEIR RESPECTIVE
# OFFICERS, DIRECTORS, EMPLOYEES, OR AGENTS BE LIABLE WITH RESPECT TO THE WEBSITE OR
# THE COMPONENTS OR THE SERVICES UNDER ANY CONTRACT, NEGLIGENCE, TORT, STRICT
# LIABILITY OR OTHER LEGAL OR EQUITABLE THEORY (I)FOR ANY AMOUNT IN THE AGGREGATE IN
# EXCESS OF THE GREATER OF FEES PAID BY YOU THEREFOR OR $100; (II) FOR ANY INDIRECT,
# INCIDENTAL, PUNITIVE, OR CONSEQUENTIAL DAMAGES OF ANY KIND WHATSOEVER; (III) FOR
# DATA LOSS OR COST OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; OR (IV) FOR ANY
# MATTER BEYOND ACTION1’S REASONABLE CONTROL. SOME STATES DO NOT ALLOW THE
# EXCLUSION OR LIMITATION OF INCIDENTAL OR CONSEQUENTIAL DAMAGES, SO THE ABOVE
# LIMITATIONS AND EXCLUSIONS MAY NOT APPLY TO YOU.
$registryPath = "HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server"
$registryKey = "fDenyTSConnections"
try{
$RdpEnabled = Get-ItemProperty -Path $registryPath -Name $registryKey -ErrorAction Stop
$Status = $RdpEnabled.$registryKey
$OutputText = $(if($status-eq 0){'True'}else{'False'})
}
catch{
$OutputText = "Error: $_"
}
$OutputText
Action1-Set-CustomAttribute 'RDP Enabled' $OutputText