Skip to content
Menu

Remote Desktop Open to the Internet or Without NLA

Checks Remote Desktop settings, NLA and inbound TCP rules for the RDP port. It flags broad sources, an off firewall profile or missing NLA when RDP is on.

Remote Desktop open to the internet or without NLA is free for members.

Enter your email to create your free account and get the file.

We'll email you the script and the weekly MSP Outpost email. Unsubscribe anytime. Privacy policy.

Already a member? Sign in.

Be the first to review Remote Desktop open to the internet or without NLA. Tell other MSPs how it worked for you.

Write a Review

LanguagePowerShell
Runs onWindows 10, Windows 11, Windows Server 2016+; runs as SYSTEM
NeedsPowerShell 5.1; NetSecurity module; administrator rights
Read-onlyReads, changes nothing

What It Does

The script is read-only. It reads, as Windows enforces them, where a Group Policy value wins over the local one, whether Remote Desktop connections are allowed, whether Network Level Authentication is required, the listening port and the RDP security layer. When Remote Desktop is on, it reads every enabled inbound Allow rule in the active firewall store, domain Group Policy included, for that TCP port, and the remote addresses each rule accepts.

It alerts when Remote Desktop is on and a rule accepts Any address, Internet or a 0.0.0.0/0 range, or, when AllowedSources is set, accepts an address outside it. It also alerts when Remote Desktop is on and NLA is not required. The keywords LocalSubnet, Intranet, DefaultGateway, DHCP, DNS and WINS are treated as local and are fine.

A rule is counted when it names the RDP TCP port or a numeric range that includes it. Rules for any port and Block rules are outside the check. It reports local listener state without testing external reachability. A firewall profile that is off while Remote Desktop is on also alerts. A weak security layer, 0, is shown but does not alert on its own.

Before You Run It

  • Set AllowedSources to your management ranges if you want rules accepting other addresses to alert.
  • Know that rules opening every port, and Block rules, are not evaluated.
  • Fix findings by restricting the rule's RemoteAddress, or by turning Remote Desktop off.
  • Schedule it in your RMM and alert on exit 1.

Type and Risk

  • Type: Monitor. It checks one condition. It exits 1 when it finds the problem, so your RMM can alert on it, 0 when all is well, and 2 when it could not run.
  • Risk: Low. It reads and changes nothing.
  • Restart: It never restarts the machine.
  • Typical run: Under 20 seconds.
  • Example answer: "RDP is on and reachable from any address via Remote Desktop - User Mode (TCP-In); restrict the rule's RemoteAddress; NLA is not required"
  • Tested before listing on Windows 11 with Windows PowerShell 5.1, run as SYSTEM, against its own test cases.

Inputs

Pass an input as an argument (-Name value), as an environment variable with the same name, which is how most RMMs pass script variables, or change its default in the param() block at the top of the script. An argument wins over an environment variable, which wins over the default.

  • AllowedSources: Addresses, CIDR blocks (10.0.0.0/24) or ranges (10.0.0.1-10.0.0.9) from which Remote Desktop is acceptable, separated by commas. When set, a rule that accepts any address outside them alerts. Default none (only Any/Internet alerts).

Every script also takes DryRun, OutputFormat (Text, Answer, Json or Csv), ExportPath and ResultField, which writes the answer to an RMM custom field.

License

Provided "as is" under the MIT License, without warranty of any kind. Test before production use. MSP Outpost and User First Digital Inc. accept no liability for any damage or loss.

The Script

test-rdp-exposure.ps1 · 935 lines · 48.8 KB

Free for Members

Create a free account or sign in to read, copy and download this script.

Welcome Back

Sign in to your MSP Outpost account.