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