Skip navigation
Enable Remote Desktop using PowerShell

Enable Remote Desktop using PowerShell

Q. How can I enable Remote Desktop through PowerShell?

A. I recently created a new shielded VM but forgot to enable RDP before shielding it and once shielding is enabled you can no longer access the console. Luckily WS-Man is enabled by default and I found its IP address through Hyper-V. I therefore created a remote PowerShell session (New-PSSession and Enter-PSSession) into the VM then ran the following to enable RDP:

# Enable Remote Desktop
(Get-WmiObject Win32_TerminalServiceSetting -Namespace root\cimv2\TerminalServices).SetAllowTsConnections(1,1) | Out-Null
(Get-WmiObject -Class "Win32_TSGeneralSetting" -Namespace root\cimv2\TerminalServices -Filter "TerminalName='RDP-tcp'").SetUserAuthenticationRequired(0) | Out-Null
Get-NetFirewallRule -DisplayName "Remote Desktop*" | Set-NetFirewallRule -enabled true


Hide comments


  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.