3

#PSTip Enabling remote desktop access firewall rules in Windows 8 and Windows Server 2012

Note: This tip requires PowerShell 3.0 or above.

In a couple of earlier posts, we looked at how we can get firewall rules and add new rules. In this post, we shall see an example of extending this knowledge to enable firewall rule for remote desktop access.

There is a built-in firewall rule that needs to enabled for allowing remote desktop access. Make a note that this is not about enabling remote desktop but ensuring that we allow remote desktop access in Windows Firewall.

First, let us see how we can check if the remote desktop firewall rule is enabled:

Get-NetFirewallRule -DisplayName "Remote Desktop*" | Select DisplayName, Enabled

When you run the above command, you will see two firewall rules – “Remote Desktop – User Mode (TCP-In)” and “Remote Desktop – User Mode (UDP-In)”.

We have to enable both these rules to ensure we allow remote desktop access through Windows Firewall.

Get-NetFirewallRule -DisplayName "Remote Desktop*" | Set-NetFirewallRule -enabled true

That is it! You will see that the remote desktop firewall rules are now enabled.

Filed in: Columns, Tips and Tricks Tags: , , ,
  • jtuck004

    Got a follow up on this?

    I am accessing my server from a Win 8 machine with RSAT. In Server 2012 I enabled the “Remote Desktop”

    So I disabled that and ran the first command, which then returned “false” for the value of “Enabled”, as it should. And it dropped my RD session. So good so far.
    Ran the second command, and checked it again. Now it returns the value of “True” for both values.
    Back into Server Mgr GUI, refreshed, still shows disabled. (configure-smremoting works, and the change is reflected in the gui too, btw).
    Tried to connect with “Remote Desktop Session”, fails, tells me it cannot connect because
    “Remote Desktop is not enabled”
    1 – again and an RDS session from Windows 8, cannot connect, message says
    2 – The machine is off
    3 – The machine is not available on the network.
    I re-enable “Remote Desktop” in the GUI, hooks right up.
    Thoughts?

    • http://www.ravichaganti.com/blog Ravikanth

      This method/post is only about adding firewall exceptions for RDP. You still need to enable RDP using either GUI or Terminal Server commandline or WMI.

      • jtuck004

        OK, got it. It’s like opening the windows on the castle, but you still can’t get in ’cause the drawbridge across the moat hasn’t been lowered. ;)

        I thought there was a larger point to this, because I missed what you said in the intro, and since one can run scregedit and do it all in one line. But I’m sure there will come a time when I find a better use.

        Thank you for the reply, and the tip.

© 2014 PowerShell Magazine. All rights reserved. XHTML / CSS Valid.
Proudly designed by Theme Junkie.
%d bloggers like this: