Cloud VPS from $1.98/mo · pay with Bitcoin, Ethereum, Monero, USDT or Solana · paid in crypto
Security

Manage Windows Firewall with Group Policy and PowerShell

Control Windows Firewall profiles and rules with Group Policy and PowerShell, turn a profile off the supported way when you must, and keep RDP reachable.

CloudSat teamNovember 18, 20266 min read
Abstract illustration of a tree of policy branches feeding glowing rules into a Windows server window
On this pageBefore you change anything remotely

Most people who search for "disable Windows Firewall with Group Policy" are trying to make one application work. Sometimes switching the firewall off is the right call: a third-party firewall takes over, or you need ten minutes to rule the firewall out while troubleshooting. Far more often, the fix is a single rule. This guide covers both on Windows Server and Windows 11, through Group Policy for many machines and PowerShell for one, without cutting off the Remote Desktop session you are working in.

Before you change anything remotely

On a remote server, your RDP session runs through the firewall you are about to edit. Three precautions:

  1. Know your out-of-band path. On CloudSat you can request console access to the server, as described in Regain access with the recovery tools, which works even with RDP blocked.
  2. Create the rule that keeps you connected before you tighten anything else.
  3. Test from a second RDP session before you close the first.

Windows Firewall's default behavior helps: it blocks unsolicited inbound traffic unless a rule allows it, and allows outbound traffic unless a rule blocks it.

Know the three profiles

Every network connection is assigned one profile, and rules apply per profile.

Profile Applied when Typical on
Domain The machine is joined to Active Directory and can reach a domain controller Corporate servers and desktops
Private An administrator marks the network as trusted Home and office networks
Public The network is unidentified, the default Cloud servers, hotel Wi-Fi

A standalone cloud server usually sits in Public. Check with Get-NetConnectionProfile. You can switch it with Set-NetConnectionProfile, but writing rules for the profile you actually have is cleaner than relaxing the profile.

Read the current state with PowerShell

Open PowerShell as Administrator. These three commands answer most questions:

Get-NetFirewallProfile | Format-Table Name, Enabled, DefaultInboundAction, DefaultOutboundAction
Get-NetFirewallRule -Direction Inbound -Enabled True | Sort-Object DisplayName | Format-Table DisplayName, Profile, Action
Get-NetFirewallRule -PolicyStore ActiveStore | Measure-Object

The ActiveStore is what the machine actually enforces: local rules merged with rules from Group Policy. When a rule you created does not seem to work, compare the local store with the active one.

Write a rule instead of turning the firewall off

A rule opens exactly what the application needs and nothing else. Restricting the source address is the single most useful habit on an internet-facing server:

New-NetFirewallRule -DisplayName "RDP from office" -Direction Inbound -Protocol TCP -LocalPort 3389 -RemoteAddress 198.51.100.24 -Action Allow -Profile Any
New-NetFirewallRule -DisplayName "HTTPS" -Direction Inbound -Protocol TCP -LocalPort 443 -Action Allow -Profile Any

Once a new RDP session from the office address works, disable the broad built-in RDP rules so the restricted one is the only door:

Get-NetFirewallRule -DisplayGroup "Remote Desktop" | Disable-NetFirewallRule

To change a rule later, use Set-NetFirewallRule -DisplayName "RDP from office" -RemoteAddress 198.51.100.0/24. The classic netsh advfirewall firewall commands still work, but the PowerShell cmdlets are easier to script and to read back.

Configure the firewall through Group Policy

Group Policy is how you give many machines the same firewall settings. On a domain, open the Group Policy Management console, create a GPO, link it to the organizational unit that holds your servers, and edit it. The firewall lives under Computer Configuration, Policies, Windows Settings, Security Settings, Windows Defender Firewall with Advanced Security (recent Microsoft documentation shortens the name to Windows Firewall with Advanced Security). On a single machine running a Pro, Enterprise, Education or Server edition, gpedit.msc shows the same node under Computer Configuration, Windows Settings, Security Settings. Windows Home has no Group Policy editor.

The management console is not installed everywhere by default:

Install-WindowsFeature GPMC
Add-WindowsCapability -Online -Name Rsat.GroupPolicy.Management.Tools~~~~0.0.1.0

The first line is for Windows Server, the second for Windows 11 with the Remote Server Administration Tools.

Inside the node, open the firewall properties. Each profile tab sets the firewall state, the default inbound and outbound actions, and, under Customize, whether local rules still apply. That last setting, Apply local firewall rules, causes more outages than any other: set it to No and every rule created locally on the server stops counting, including the RDP rule you added by hand. Put the rules you depend on into the GPO before you switch merging off.

PowerShell can write into a GPO directly by naming it as the policy store:

New-NetFirewallRule -PolicyStore "corp.example.com\Server firewall" -DisplayName "RDP from office" -Direction Inbound -Protocol TCP -LocalPort 3389 -RemoteAddress 198.51.100.24 -Action Allow

Apply and verify on a target machine:

gpupdate /force
gpresult /scope computer /r

Without gpupdate, machines pick up changes at the next background refresh, which Microsoft documents as every 90 minutes plus a random offset of up to 30 minutes.

If you really must turn it off

Microsoft's guidance is clear: do not disable Windows Firewall if you can avoid it, because you also lose IPsec connection security rules, service hardening and boot-time filtering. When you must, turn off the profiles and leave the service running. Stopping the Windows Defender Firewall service (MpsSvc) is unsupported and can break the Start menu and app installs.

In Group Policy, set Firewall state to Off on the profile tabs of the firewall properties. Locally, use PowerShell, and write down when you will turn it back on:

Set-NetFirewallProfile -Profile Domain,Private,Public -Enabled False
Set-NetFirewallProfile -Profile Domain,Private,Public -Enabled True

On an internet-facing server, a firewall outside the machine should be in place before you try this: with every profile off, RDP, SMB and any other listening service face the internet unfiltered. A third-party firewall product does not need you to do any of this; it registers with Windows Security and disables only the parts it replaces.

When a setting will not stick

  • A GPO wins over local settings. If policy sets the firewall state, local changes are greyed out or reverted at the next refresh. gpresult /h C:\gp-report.html shows which GPO is responsible.
  • The rule exists but traffic is still blocked. Check the profile: a rule scoped to Private does nothing on a Public connection. Then check for a block rule, which beats an allow rule.
  • A role opened more than you expected. Installing roles and features adds predefined rules, for example the World Wide Web Services (HTTP Traffic-In) rule that arrives with IIS. Review the enabled inbound rules after every role installation, and disable the ones you do not serve.
  • You need evidence. Turn on logging for dropped packets with Set-NetFirewallProfile -Profile Public -LogBlocked True and read %SystemRoot%\System32\LogFiles\Firewall\pfirewall.log.

FAQ

Can I manage the firewall with Group Policy on Windows 11 Home?

No, Home has no Group Policy editor. Use the Windows Security app or the PowerShell cmdlets shown above, which work on every edition.

How fast does a Group Policy firewall change apply?

Immediately after gpupdate /force on the target, otherwise at the next background refresh, roughly every 90 to 120 minutes. Changes made through the firewall node are re-read by the firewall as soon as they reach the registry.

Is there an emergency mode that blocks everything?

Yes. The setting "Block all incoming connections, including those in the list of allowed apps", which Microsoft informally calls shields up, overrides every allow rule until you clear it. It also blocks RDP, so use it from the console, not over a remote session.

Should I change a cloud server's network to Private?

Usually not. Keep the Public profile and write the rules you need. The Windows VPS you rent faces the internet directly, which is exactly the case the Public profile was designed for.

Run it on CloudSat. Cloud VPS on AMD EPYC and NVMe from $1.98/mo in 13 regions, delivered in under 5 minutes and paid in crypto. See plans or deploy a server.