When One Firewall Rule Breaks Forty Machines
A financial services client called us on a Friday afternoon because half their branch office servers had stopped accepting inbound connections after a Group Policy update. The IPsec rules looked correct in the Group Policy Management Console, but the local machines told a different story. The root cause was straightforward once we knew where to look: someone had created conflicting IPsec rules in the local PersistentStore that were colliding with the domain-pushed policy. The fix required understanding exactly how the -PolicyStore parameter in NetIPsec cmdlets determines which layer of policy you are reading from or writing to.
That experience changed how we approach IPsec troubleshooting across every managed environment. The PolicyStore parameter is not just a filter flag — it is the lens through which PowerShell sees firewall and IPsec policy, and picking the wrong lens means you are solving the wrong problem.
What PolicyStore Actually Controls
A policy store is a container for firewall and IPsec policy in Windows. Think of it like a filing cabinet with clearly labeled drawers — each drawer holds rules from a different source, and the operating system combines them at runtime to produce the effective policy. The -PolicyStore parameter on cmdlets like Get-NetIPsecRule, Set-NetIPsecMainModeCryptoSet, and New-NetIPsecRule tells PowerShell which drawer to open.
By default, most NetIPsec cmdlets query the PersistentStore. That is the local store containing rules created manually or programmatically on the machine — not from GPOs, not from MDM, just what lives on that specific endpoint. Rules written to the PersistentStore attach to the ActiveStore and activate immediately, which is exactly why careless writes there caused our client’s outage.
The Seven Policy Stores You Need to Know
Windows Server exposes several distinct policy stores, each serving a different purpose. Here is the breakdown that we keep in our internal runbooks:
| Store Name | Read/Write | What It Contains |
|---|---|---|
PersistentStore |
Read-Write | Local static rules created manually or by application installers. The default store. |
ActiveStore |
Read-Only* | The resultant set of policy (RSOP) — the sum of all GPOs plus local stores including PersistentStore, static WSH, and configurable WSH. |
RSOP |
Read-Only | The sum of all GPOs applied to the local computer, without local store rules mixed in. |
SystemDefaults |
Read-Only | Default firewall rules that ship with Windows Server. |
StaticServiceStore |
Read-Only | Service restrictions that ship with Windows Server. Product-dependent features are included. |
ConfigurableServiceStore |
Read-Write | Service restrictions added for third-party services, plus network isolation rules for Windows Store app containers. |
MDM |
Read-Only | Rules configured through Mobile Device Management. |
The asterisk on ActiveStore matters. You can query it to see what is actually enforced, but you cannot write to it directly — you write to PersistentStore or a GPO, and the ActiveStore reflects the merged result.
Targeting GPOs Directly from PowerShell
This is where the parameter becomes genuinely powerful. Instead of opening the Group Policy Management Console, you can read and write IPsec rules directly against a specific GPO by passing its path to -PolicyStore.
For a local computer GPO:
Get-NetIPsecRule -PolicyStore localhost
For an Active Directory GPO by friendly name:
Get-NetIPsecRule -PolicyStore "corp.contoso.com\FirewallPolicy"
The syntax follows the pattern domain.fqdn.com\GPO_Friendly_Name. The GPO must already exist — create it with New-GPO or through the Group Policy Management Console first. This capability is what makes large-scale IPsec management practical. During a compliance engagement for a government contractor, we wrote a script that audited IPsec rules across twelve domain GPOs in under thirty seconds, something that would have taken an hour of clicking through the GUI. You can reference Microsoft’s Group Policy documentation for the full GPO management lifecycle.
GPOSession: The Batch Alternative
When you need to make multiple changes to a single GPO, the -GPOSession parameter offers a more efficient path. It caches the GPO locally, lets you run multiple cmdlets against that cache, and then commits the changes in one operation. Note that -GPOSession and -PolicyStore cannot be used together — they are mutually exclusive approaches to the same problem.
ActiveStore vs RSOP: A Distinction That Matters in Troubleshooting
This is where most administrators get tripped up, and it is the exact confusion that cost our financial services client four hours of downtime. The ActiveStore shows everything — GPO rules, local PersistentStore rules, WSH rules, the whole stack merged together. The RSOP store shows only the GPO-derived rules.
When you are debugging a policy conflict, start with ActiveStore to see what is actually enforced:
Get-NetIPsecRule -PolicyStore ActiveStore | Format-Table DisplayName, PolicyStoreSource, Enabled
The PolicyStoreSource property on each rule tells you where it originated — values include Local, GroupPolicy, and Dynamic. If you spot a rule with source Local that conflicts with a GroupPolicy rule, you have found your problem. This is a pattern we document in our incident response procedures, and it maps well to the kind of scoping awareness that good PowerShell practice demands.
Then compare against RSOP to see the GPO-only picture:
Get-NetIPsecRule -PolicyStore RSOP | Format-Table DisplayName, Direction, Action
The delta between these two views is your local policy. That delta is either intentional or it is the source of your outage.
Practical Patterns for Managed Environments
Auditing Across Multiple Stores
For compliance work — especially against frameworks like CIS Benchmarks — we run a quick comparison script that pulls rules from PersistentStore and RSOP side by side. Any rule in PersistentStore that does not have a corresponding GPO rule gets flagged for review. In environments where we manage bare metal restore and backup infrastructure, these local rules sometimes exist because a backup agent installer created them during deployment. They are usually legitimate, but they need to be documented.
Avoiding the Set-NetIPsecMainModeCryptoSet Trap
One important caveat: Set-NetIPsecMainModeCryptoSet cannot be used to add an object to a policy store. It modifies existing crypto sets only. If you need to create a new crypto set in a specific store, use New-NetIPsecMainModeCryptoSet with the -PolicyStore parameter. This trips up scripters who assume all Set- cmdlets can upsert.
SystemDefaults as a Baseline Reference
The SystemDefaults store is underused. It contains the firewall rules that shipped with Windows Server, giving you a clean baseline to compare against. When a client asks whether a rule is custom or factory, this store answers the question definitively:
Get-NetIPsecRule -PolicyStore SystemDefaults | Measure-Object
My Position: Always Specify PolicyStore Explicitly
I take a firm stance on this with every client engagement: never rely on the default PersistentStore behavior in production scripts. Always pass -PolicyStore explicitly, even when you want PersistentStore. The three seconds it takes to type the parameter save hours of debugging when someone copies your script into a context you did not anticipate. It is the same principle behind explicit variable scoping in PowerShell automation scripts — implicit defaults are fine for interactive sessions but dangerous in production code.
This also applies to detection rule management in security operations. When your IPsec policies feed into a broader security posture, knowing exactly which store you are querying is not optional — it is the difference between accurate telemetry and noise.
The Takeaway for Your Next IPsec Deployment
The PolicyStore parameter is a policy routing mechanism. It determines whether your PowerShell command touches local rules, domain rules, the merged active set, or a read-only baseline. Get it wrong and you are either reading stale data or writing rules to the wrong layer. Get it right and you have precise, auditable control over IPsec policy across every endpoint in the domain.
If your environment has accumulated local IPsec rules that nobody can explain, or if GPO-pushed policies are not behaving as expected, that is exactly the kind of mess we untangle regularly. Reach out to our team and we will audit the policy stack before it causes an outage at the worst possible time.


