PS – Enable RDP remotely

By default on a Windows Server Product Windows Remote Management (WinRM) is enabled, but Remote Desktop (RDP) is Disabled.  On workstation operating systems neither is enabled by default, so if you want to be able to accomplish the following you will need to enable WinRM on the workstations.Enabling RDP remotely.Method 1:  Command LineTo enable RDP with the Command Prompt, use the following steps

Launch the Command Prompt as Administrator. and type the following command:

Reg add\\computername\HKLM\SYSTEM\CurentControlSet\Control\Terminal Server/v fDenyTSConnections /tREG_DWORD /d /f

Note:  Computername is the name of the computer you wish to enable RDP on.NOTE:  Enabling RDP through the Command Prompt will not configure the Windows Firewall with the appropriate ports to allow RDP connections.NOTE:  By default the local Administrators group will be allowed to connect with RDP.  Also the user that is currently logged in will also be allowed to connect.To disable RDP with the Command Prompt, use the following steps.Launch the Command Prompt as Administrator. and type the following command:

Reg add “\\computername\HKLM\SYSTEM\CurentControlSet\Control\Terminal Server/vfDenyTSConnections /tREG_DWORD /d 1 /f

Method 2:  Using PowerShellTo enable RDP with the PowerShell, use the following steps.Option 1To enable RDP:Launch PowerShell as Administrator. and type the following command and create a script block and use the Invoke-Command cmdlet:

InvokeCommand –Computername “server1,Server2” –ScriptBlock {SetItemProperty Path“HKLM:\System\CurrentControlSet\Control\Terminal Server” Name“fDenyTSConnections” –Value }

NOTE:  Enabling RDP through PowerShell will not configure the Windows Firewall with the appropriate ports to allow RDP connections.Type the following:

InvokeCommand –Computername “server1,Server2” –ScriptBlock {EnableNetFirewallRule DisplayGroup“Remote Desktop”}

NOTE:  By default the local Administrators group will be allowed to connect with RDP.  Also the user that is currently logged in will also be allowed to connect.To disable RDP with the PowerShell, use the following steps.Launch PowerShell as Administrator. and type the following command:

InvokeCommand –Computername “server1,Server2” –ScriptBlock {SetItemProperty Path“HKLM:\System\CurrentControlSet\Control\Terminal Server” Name“fDenyTSConnections” –Value 1}

To enable RDP RDP with the PowerShell, use the following steps.Launch PowerShell as Administrator.Create a PS Session with the desired target computer. and type the following command once possession is established:

SetItemProperty Path“HKLM:\System\CurrentControlSet\Control\Terminal Server” Name“fDenyTSConnections” –Value
EnableNetFirewallRule DisplayGroup “Remote Desktop”
Set–ItemProperty –Path“HKLM:\System\CurrentControlSet\Control\Terminal Server” –Name“fDenyTSConnections” –Value 1