File tree 1 file changed +10
-8
lines changed
1 file changed +10
-8
lines changed Original file line number Diff line number Diff line change @@ -24,20 +24,22 @@ function Set-RDPEnable {
24
24
@lazywinadmin
25
25
#>
26
26
27
- [CmdletBinding ()]
27
+ [CmdletBinding (SupportsShouldProcess = $true )]
28
28
PARAM (
29
29
[String []]$ComputerName = $env: COMPUTERNAME
30
30
)
31
31
PROCESS {
32
32
FOREACH ($Computer in $ComputerName ) {
33
33
TRY {
34
- IF (Test-Connection - ComputerName $Computer - Count 1 - Quiet) {
35
- $regKey = [Microsoft.Win32.RegistryKey ]::OpenRemoteBaseKey([Microsoft.Win32.RegistryHive ]::LocalMachine, $Computer )
36
- $regKey = $regKey.OpenSubKey (" SYSTEM\\CurrentControlSet\\Control\\Terminal Server" , $True )
37
- $regkey.SetValue (" fDenyTSConnections" , 0 )
38
- $regKey.flush ()
39
- $regKey.Close ()
40
- } # IF Test-Connection
34
+ IF ($PSCmdlet.ShouldProcess ($Computer , " Enable Remote Desktop" )) {
35
+ IF (Test-Connection - ComputerName $Computer - Count 1 - Quiet) {
36
+ $regKey = [Microsoft.Win32.RegistryKey ]::OpenRemoteBaseKey([Microsoft.Win32.RegistryHive ]::LocalMachine, $Computer )
37
+ $regKey = $regKey.OpenSubKey (" SYSTEM\\CurrentControlSet\\Control\\Terminal Server" , $True )
38
+ $regkey.SetValue (" fDenyTSConnections" , 0 )
39
+ $regKey.flush ()
40
+ $regKey.Close ()
41
+ } # IF Test-Connection
42
+ }
41
43
} # Try
42
44
CATCH {
43
45
$PSCmdlet.ThrowTerminatingError ($_ )
You can’t perform that action at this time.
0 commit comments