Consider the following scenario: There’s a switched on client computer in a branch office and you want to connect to that computer via remote desktop. Remote desktop is disabled by default on all Windows operating systems. There’s no user logged on this client computer and no one can help you to enable remote desktop. What do you do then? The answer is: Do some PowerShell remote actions!
The following only works if WinRM is enabled. Since Windows Server 2012 WinRM is enabled by default on all Windows server operating systems, but not on client operating systems. To enable WinRM on your client computers see: Group Policies: Enabling WinRM for Windows Client Operating Systems (Windows 10, Windows 8, Windows 7)
Enabling Remote Desktop with PowerShell Remoting
It is assumed that WinRM is enabled on the target host. I have two computers: azdc01 and client01. On client01 remote desktop is disabled. Now I run the following command to enable remote desktop on client01:
Invoke-Command -ComputerName client01 ` {Set-ItemProperty ` -Path 'HKLM:\System\CurrentControlSet\Control\Terminal Server'` -Name "fDenyTSConnections" -Value 0; ` Enable-NetFirewallRule -DisplayGroup "Remote Desktop"}
Finally, let’s do some checks. Port 3389 should be open now, right?
From now on you are able to establish a remote desktop connection to your remote host.
Categories: PowerShell, Windows 10, Windows Server
Hi Patrick ,
We do have some duplicate objects that need to be deleted but no special tool needed.
object are in the lostandfound dir
LikeLike
How can we put theese codes into a menu to have the possibility to return to main menu? Like:
Main menu:
1 – Type Computer Name
Result: Remote desktop enabled, type 1 to return to main menu or any key to exit
2 – Test RD port 3389
Result: Remote desktop works, type 1 to return to main menu or any key to exit
0 – Exit
LikeLike
You can create menus with PowerShell. Have a look at my AD tool for inspiration
LikeLike
Can you also provide the code for the “disable” mode?
Do I just need tot change “0” to “1”?
LikeLike
You are right. Only charge it to 1.
LikeLike