Enable Remote Desktop Using PowerShell

Open an elevated Windows PowerShell session and run the following commands. This first one creates the fDenyTSConnections value and sets it to 0 (off). This makes sense, because we don’t want to deny Terminal Services (TS) connections.

Set-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server' -Name fDenyTSConnections -Value 0

Set Network Level Authentication for Remote Desktop

Set-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp'-Name UserAuthentication -Value 1

Setting Firewall Rules :

Set-NetFirewallRule -DisplayGroup 'Remote Desktop' -Enabled True

Since you’re using Server 2012 which means PowerShell remoting is enabled.

Set-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server' -Name fDenyTSConnections -Value 0
Set-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp' -Name UserAuthentication -Value 1
Set-NetFirewallRule -DisplayGroup 'Remote Desktop' -Enabled True

you can throw all of this in the script block of Invoke-Command to remotely enable RDP

Invoke-Command -ComputerName ThatLazySRV01 -ScriptBlock {Set-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server' -Name fDenyTSConnections -Value 0Set-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp' -Name UserAuthentication -Value 1Set-NetFirewallRule -DisplayGroup 'Remote Desktop' -Enabled True}

Sharing is caring!

Source: http://www.thatlazyadmin.com/enable-remote-desktop-using-powershell/