Skip to content

Commit f953654

Browse files
committed
Add support for whatif
1 parent 75c6901 commit f953654

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

Diff for: TOOL-Set-RDPEnable/Set-RDPEnable.ps1

+10-8
Original file line numberDiff line numberDiff line change
@@ -24,20 +24,22 @@ function Set-RDPEnable {
2424
@lazywinadmin
2525
#>
2626

27-
[CmdletBinding()]
27+
[CmdletBinding(SupportsShouldProcess = $true)]
2828
PARAM (
2929
[String[]]$ComputerName = $env:COMPUTERNAME
3030
)
3131
PROCESS {
3232
FOREACH ($Computer in $ComputerName) {
3333
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+
}
4143
} #Try
4244
CATCH {
4345
$PSCmdlet.ThrowTerminatingError($_)

0 commit comments

Comments
 (0)