Account with administrative privilegies on the remote computer. PowerShell on the local machine. Windows 2012 and up on the remote server.

  1. Open remote powershell session:

    PS C:\> Enter-PSSession -ComputerName SRV1   
  2. Enable RDP:

    [SRV1]: PS C:\> Set-ItemProperty -Path ‘HKLM:\System\CurrentControlSet\Control\Terminal Server’-name “fDenyTSConnections” -Value 0   
  3. Enable RDP in the Firewall:

    [SRV1]: PS C:\> Enable-NetFirewallRule -DisplayGroup “Remote Desktop”   

To check is RDP enabled:

[SRV1]: PS C:\> Get-ItemProperty -Path ‘HKLM:\System\CurrentControlSet\Control\Terminal Server’-name “fDenyTSConnections”   

To check if RDP is enabled in the Firewall:

[SRV1]: PS C:\> Get-NetFirewallRule -DisplayGroup "Remote Desktop" | format-table Name, Enabled -autosize   

To exit remote powershell session type exit