forked from lazywinadmin/PowerShell
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSet-RDPEnable.ps1
More file actions
53 lines (46 loc) · 1.1 KB
/
Copy pathSet-RDPEnable.ps1
File metadata and controls
53 lines (46 loc) · 1.1 KB
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
function Set-RDPEnable
{
<#
.SYNOPSIS
The function Set-RDPEnable enable RDP remotely using the registry
.DESCRIPTION
The function Set-RDPEnable enable RDP remotely using the registry
.PARAMETER ComputerName
Specifies the ComputerName
.EXAMPLE
PS C:\> Set-RDPEnable
.EXAMPLE
PS C:\> Set-RDPEnable -ComputerName "DC01"
.EXAMPLE
PS C:\> Set-RDPEnable -ComputerName "DC01","DC02","DC03"
.NOTES
Francois-Xavier Cat
www.lazywinadmin.com
@lazywinadm
#>
[CmdletBinding()]
PARAM (
[String[]]$ComputerName = $env:COMPUTERNAME
)
PROCESS
{
FOREACH ($Computer in $ComputerName)
{
TRY
{
IF (Test-Connection -ComputerName $Computer -Count 1 -Quiet)
{
$regKey = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey([Microsoft.Win32.RegistryHive]::LocalMachine, $Computer)
$regKey = $regKey.OpenSubKey("SYSTEM\\CurrentControlSet\\Control\\Terminal Server", $True)
$regkey.SetValue("fDenyTSConnections", 0)
$regKey.flush()
$regKey.Close()
} #IF Test-Connection
} #Try
CATCH
{
$Error[0].Exception.Message
} #Catch
} #FOREACH
} #Process
}