How to remotely enable Remote Desktop (RDP) using PowerShell

If you want to remotely enable Remote Desktop (RDP) on the server, but you have not access to the terminal, we will show you how to do it by using Powershell. In our case we are usingserver on 2012 R2 platform. It should be noted that Windows Server 2012 R2 already has PowerShell, so we can easily use some scripts to solve this problem.

Enable RDP Remotely Using PowerShell

First of all we need to establish a session with the remote server. To do this just use the command:

Enter-PSSession -ComputerName server.domain.local -Credential domain\administrator

Now we need to actually enable Remote Desktop.

Set-ItemProperty -Path 'HKLM:\System\CurrentControlSet\Control\Terminal Server'-name "fDenyTSConnections" -Value 0

Once it is done, activate the firewall rule.

Enable-NetFirewallRule -DisplayGroup "Remote Desktop"

After that you should enable authentication via RDP.

Set-ItemProperty -Path 'HKLM:\System\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp' -name "UserAuthentication" -Value 1

You may also like:

Add Calendar Permissions in Office 365 via Powersh... This is a tutorial on how to add calendar permissions in Office 365 for your users via Powershell. You can add permissions onto a specific mailbox, or...
Windows Server 2008 – Multiple RDP Sessions In Windows Server 2008 and Windows Server 2008 R2, multiple remote desktop sessions is not configured by default. Multiple RDP Sessions Here is a qu...
How to copy files with BITS using PowerShell If you use local (and global) networks, you might know that files between systems are transferring by using SMB, FTP or HTTP protocols. The problem wi...
Grant Full Access to All Mailboxes in Exchange 200... This is a short tutorial on how to add full access to all mailboxes in Exchange 2007 and 2010 for a an additional user. This can come in handy when sa...
How to Get List of Installed Programs in Windows 1... In this simple guide we will show you two different ways of how to get list of installed programs in Windows 10, 8 or Windows 7 using built-in command...