We help IT Professionals succeed at work.

PowerShell 4.0 : How to enable remote desktop on remote computer ?

Thenkung
Thenkung asked
on
To Expert

PowerShell 4.0 : How to enable remote desktop on remote computer and How to allow remote desktop on windows firewall?

Best Regard
Comment
Watch Question

Messaging and Directory Services
Commented:
$server="SERVERNAME"
$rdpobject = Get-WmiObject -Class Win32_TerminalServiceSetting -Namespace root\CIMV2\TerminalServices -ComputerName $server -Authentication 6 

$status = $rdpobject.setAllowTsConnections(1,1)
   if($status.returnValue -eq 0) {
   Write-Host "Enabled RDP Successfully on $server"
 } else {
   Write-Host "$server: Error"
}

 Enable-NetFirewallRule -DisplayGroup "Remote Desktop"  

Open in new window

Qlemo"Batchelor", Developer and EE Topic Advisor
Top Expert 2015

Commented:
The firewall rules should be active automatically.
Top Expert 2014

Commented:
If it were me I would say this is better accomplished with Group Policy, at least in a domain environment.

Author

Commented:
Thank you so much