I'm reaching out because I'm encountering some unusual behavior with the Local Security Policy and firewall rules in Windows. My goal is to allow some agents to use certain third-party hardware that requires specific firewall ports to be open in the local security policy. According to Microsoft, these rules should function independently of an internet connection, unlike the network-facing Defender firewall.
I've created a PowerShell script to automate the creation of three local security settings for the firewall rules using the 'New-NetFirewallRule' command. Interestingly, when I manually create these rules, everything works as expected. However, when they're generated via the script, they appear under the Local Security Policy but behave as if they're Controlled by the Defender firewall, meaning they cease to function when there's no internet connection. This discrepancy is puzzling to me, especially given my 23 years of experience. Any insights would be greatly appreciated!
Just to clarify, this isn't related to a Group Policy Object (GPO); it's a script meant for a small group of field engineers to add rules efficiently without needing to do it manually one by one. It's also worth noting that the local security policy isn't the same as the Defender firewall settings, as they govern different aspects of network control.
2 Answers
It sounds like there's a bit of confusion about how Windows Firewall manages rules. Regardless of how you're configuring these rules, what you're dealing with are still Windows Firewall settings. The firewall should enforce rules as long as it's active, regardless of the internet connection.
If it's feasible, I advise you to tweak these rules directly through the Windows Firewall Advanced settings using the GUI, instead of dealing with local group policy in a script.
If I may add, sharing part of your script could help diagnose the issue. You could also consider using the `NETSH` command for better control over your firewall configurations.
That said, remember that Windows actually separates local policy from the external-facing firewall, which could be why you're seeing these odd behaviors.
Related Questions
Can't Load PhpMyadmin On After Server Update
Redirect www to non-www in Apache Conf
How To Check If Your SSL Cert Is SHA 1
Windows TrackPad Gestures