Genz
Rajesh Radhakrishnan
21/09/2018 Published 3 weeks ago
Share
https://vmarena.com/wp-content/uploads/2024/11/gradient-website-hosting-illustration_23-2149246882-1.jpg

How to Enable Remote Desktop (RDP) Remotely Using PowerShell

Imagine about a situation where you cannot access your virtual machines through VM console and there is no RDP enabled and your Critical Application is Down .Recently I faced this challenge  and was not able to open windows 2012 R2 VM console from vSphere Web and  Thick Client and Application Down , its happened After windows update and VMware update . I tried from server manager option enable and RDP  and that option also grayed out from DC , Finally i used power shell to enable RDP  .

 

You can remotely enable Remote Desktop (RDP) on the server  using Powershell from DC or any other server which is reachable to the target server . Here we are using Windows 2012 R2 platform.

Enable RDP Remotely Using PowerShell

First of all we need to establish a session with the remote server by following below command and it will prompt for the password , and you have type the password to get access

Establish a session with Remote Session

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

 

Note :- You can see from screen as connection established and session is with the Server Name [VMARENA-BKP-01] : PS

Enable Remote Desktop

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

Activate the firewall rule

Enable-NetFirewallRule -DisplayGroup "Remote Desktop"

Enable authentication via RDP

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

 

Now try to do a Remote Desktop session , it will work .