Enable Windows Remote Desktop Protocol and Set Firewall Rules using PowerShell

powershell

Last updated on April 17th, 2023 at 12:34 am

Read Time:45 Second

If you are using Windows Server 2012 or newer, or if you are just using Windows Server Core, then this Powershell script will help you out by enabling Remote Desktop and setting the correct firewall inbound rules.

Simply open up an elevated Powershell command box, or use Powershell ISE and use the two scripts below, one to enable Remote Desktop and then the second to set the firewall ports correctly.

Enable Remote Desktop

(Get-WmiObject Win32_TerminalServiceSetting -Namespace root\cimv2\TerminalServices).SetAllowTsConnections(1,1)
(Get-WmiObject -Class “Win32_TSGeneralSetting” -Namespace root\cimv2\TerminalServices -Filter “TerminalName=’RDP-tcp'”).SetUserAuthenticationRequired(0)

Enable Inbound Firewall Rule

Enable-NetFirewallRule -DisplayGroup “Remote Desktop”

Now if you try and remote desktop on your server, it should prompt for a login and go straight in.

Feedback

If you have any questions or feedback on this article, please feel free to leave us a message below in our comments section.

Click to rate this post!
[Total: 0 Average: 0]

Free Subscription

If you want to be notified when we post more quality guides like this one, sign up to our free subscription service and you will receive an email when a new post is live.

Join 441 other subscribers.

No need to worry, we will not be filling your inbox with spam and you can unsubscribe anytime you like.


12 thoughts on “Enable Windows Remote Desktop Protocol and Set Firewall Rules using PowerShell

  1. ” Enable-NetFirewallRule -DisplayGroup “Remote Desktop” ”

    How enable this is use only domain?

    1. You could use a Get and then Enable method. So you could try something like this:

      Get-NetFirewallRule | Where {$.DisplayGroup -eq “Remote Desktop” -and $.Profile -eq “Domain”} | Enable-NetFirewallRule

  2. ” Enable-NetFirewallRule -DisplayGroup “Remote Desktop” ”

    How enable this is use only domain?

    1. You could use a Get and then Enable method. So you could try something like this:

      Get-NetFirewallRule | Where {$_.DisplayGroup -eq “Remote Desktop” -and $_.Profile -eq “Domain”} | Enable-NetFirewallRule

  3. ” Enable-NetFirewallRule -DisplayGroup “Remote Desktop” ”

    How enable this is use only domain?

    1. You could use a Get and then Enable method. So you could try something like this:

      Get-NetFirewallRule | Where {$_.DisplayGroup -eq “Remote Desktop” -and $_.Profile -eq “Domain”} | Enable-NetFirewallRule

Leave us a message...

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