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


Once completed, review your list carefully.


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"}}


Check your settings

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


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

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


Nice one.

For enabling Remote Desktop via Group Policy see this article:


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 replies »

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 )

Facebook photo

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

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.