SID-500

Home » PowerShell » PowerShell: Enable Remote Desktop on multiple Servers remotely (Bulk)

PowerShell: Enable Remote Desktop on multiple Servers remotely (Bulk)

In this article I show how to activate Remote Desktop on multiple server systems in an active directory environment by using Windows PowerShell. In large environments, it might be necessary to enable Remote Desktop on a huge number of computers. This article will help you out saving time.

Get a list of your Servers

First, we have to retrieve a list of the target systems. Log on to one of your Domain Controllers. To save the name of all server systems of your domain (Memberserver + Domain Controller) to a file run

(Get-ADComputer -Filter 'operatingsystem -like "*server*"').Name | Out-File C:\Temp\Servers.txt

Unbenannt.PNG

Once completed, review your list carefully.

Unbenannt.PNG

Activate Remote Desktop on multiple Server Systems remotely

Now we call the shots. Run the following code to activate RD on all servers in the list and configure the Windows Firewall exeption for the Remote Desktop Group.

Get-Content C:\Temp\Servers.txt | ForEach-Object {Invoke-Command -ComputerName $_ {Set-ItemProperty -Path 'HKLM:\System\CurrentControlSet\Control\Terminal Server'-Name "fDenyTSConnections" -Value 0;Enable-NetFirewallRule -DisplayGro
up "Remote Desktop"}}

Unbenannt.PNG

Check your settings

On one of the servers open Server-Manager and check the status of Remote Desktop.

Unbenannt.PNG

Next, run the following command to check all remote desktop firewall rules.

Get-NetFirewallRule -DisplayGroup "Remote Desktop" | Select-Object DisplayName,Enabled,Profile,Direction,Action

Unbenannt.PNG

Nice one.

For enabling Remote Desktop via Group Policy see this article:

https://social.technet.microsoft.com/wiki/contents/articles/4980.how-to-enable-or-disable-remote-desktop-via-group-policy-windows-2008.aspx

See also

See also my other articles about remoting:

PowerShell: Documenting your environment by running systeminfo on all Domain-Computers

How to schedule software installation with PowerShell

Windows Server: List all installed Roles and Features using PowerShell

Restart all Domain Computers by using PowerShell


4 Comments

  1. […] PowerShell: Enable Remote Desktop on multiple Servers remotely (Bulk) […]

    Like

  2. […] PowerShell: Enable Remote Desktop on multiple Servers remotely (Bulk) […]

    Like

  3. […] PowerShell: Enable Remote Desktop on multiple Servers remotely (Bulk) […]

    Like

  4. […] PowerShell: Enable Remote Desktop on multiple Servers remotely (Bulk) […]

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Categories

WHOIS

My name is Patrick Grünauer (pewa2303). I am from Austria. On sid-500 I write about Windows, Cisco and IT-Security in English and German. Have fun while reading!

Patrick Gruenauer
Follow SID-500 on WordPress.com