Enable Remote Desktop using PowerShell

Enable Remote Desktop and the required firewall exceptions using PowerShell

John Savill

September 2, 2016

1 Min Read
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 rootcimv2TerminalServices).SetAllowTsConnections(1,1) | Out-Null(Get-WmiObject -Class "Win32_TSGeneralSetting" -Namespace rootcimv2TerminalServices -Filter "TerminalName='RDP-tcp'").SetUserAuthenticationRequired(0) | Out-NullGet-NetFirewallRule -DisplayName "Remote Desktop*" | Set-NetFirewallRule -enabled true

 

About the Author(s)

Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.

You May Also Like