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

To Expert

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

Best Regard
ThenkungAsked:
Who is Participating?
 
Raheman M. AbdulSenior Infrastructure Support Analyst & Systems DeveloperCommented:
$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

0
 
QlemoBatchelor, Developer and EE Topic AdvisorCommented:
The firewall rules should be active automatically.
0
 
footechCommented:
If it were me I would say this is better accomplished with Group Policy, at least in a domain environment.
0
 
ThenkungAuthor Commented:
Thank you so much
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.