What It Does
The script checks that the Domain, Private and Public firewall profiles are all enabled and that none allows inbound connections by default. It then lists every enabled inbound allow rule whose remote address is any, on Remote Desktop (3389), SMB (445), WinRM (5985 and 5986), SSH (22) or Telnet (23), unless the port is in AllowedPorts.
It reads the settings in force, so rules from domain Group Policy count. A rule limited to a program or service is still flagged, because the built-in Remote Desktop, SMB and WinRM rules all are. A rule limited to a subnet or a list of addresses is not open to anyone and is not flagged.
On a workstation where another firewall product is turned on in Windows Security Center, that product is listed, and a Windows profile that is off is not an alert.
Before You Run It
- List ports you deliberately leave open in AllowedPorts, or every machine with them will alert.
- Expect domain controllers and file servers to show SMB. Decide whether that is an exception for them before scheduling.
- A rule open to any address on a laptop matters most on the Public profile. Read the profile column.
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: "Public profile is off; 3389 open to any address (Remote Desktop - User Mode (TCP-In))"
- 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.
- AllowedPorts: Ports that are fine to leave open to any address, separated by commas, e.g. "3389, 445". Whole numbers 1 to 65535. Default none.
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.