-
Notifications
You must be signed in to change notification settings - Fork 0
/
EnableRDP_Assist.ps1
33 lines (30 loc) · 1.18 KB
/
EnableRDP_Assist.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
<#
- Run as Highest Privileges <> Configuration Type - COMPUTER
- Description:
+ Enable Remote Desktop & Allow Firewall
+ Add Localgroup "Remote Desktop Users" for All Users
#>
<# Add User to Localgroup "Remote Desktop Users" #>
$UserName = $env:COMPUTERNAME.Split("-")[0]
# $COMPUTERNAME[0]
$GroupName = "Remote Desktop Users"
try {
Add-LocalGroupMember -Group $GroupName -Member $UserName -ErrorAction Stop
} catch [Microsoft.PowerShell.Commands.MemberExistsException] {
Write-Warning "$UserName already in $GroupName"
}
<# Enable Firewall Remote Desktop Connection #>
Set-NetFirewallProfile -All -Enabled True
Enable-NetFirewallRule -DisplayGroup "Remote Desktop"
<# Enable Remote Desktop in Regedit #>
$RegeditPath="HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server"
Set-Location -Path $RegeditPath
$key = try {
Get-Item -Path $RegeditPath -ErrorAction Stop
}
catch {
New-Item -Path $RegeditPath -Force
}
New-ItemProperty -Path $key.PSPath -Name AllowTSConnections -Value 0 -Force
New-ItemProperty -Path $key.PSPath -Name fDenyTSConnections -Value 0 -Force
New-ItemProperty -Path $key.PSPath -Name fAllowToGetHelp -Value 1 -Force