Remotely Enable Remote Desktop via Powershell

Home / Microsoft / Remotely Enable Remote Desktop via Powershell

powershellI’ve been working on project recently for a customer and needed to remotely enable remote desktop on several servers but they were located in a dark datacentre and there was no console access available.  I know you can always enable this by editing the registry but this requires a server reboot which was not an option for me.  So I decided to have a look at Powershell and found that the following commands enabled remote desktop without the need for a reboot.

(GetWmiObject Win32_TerminalServiceSetting -Computername ServerNameHere Namespace root\cimv2\TerminalServices).SetAllowTsConnections(1,1) | OutNull

(GetWmiObject Class “Win32_TSGeneralSetting” -Computername ServerNameHere Namespace root\cimv2\TerminalServices Filter “TerminalName=’RDP-tcp’”).SetUserAuthenticationRequired(0) | OutNull

Leave a Reply

Your email address will not be published. Required fields are marked *