Skip to content
Menu

Someone Changed a GPO - Alert on Any GPO Change

Compares all GPOs with the last run's snapshot and alerts on any added, removed or modified GPO, with the changing account when the audit log has it. Changes nothing in the domain.

Someone changed a GPO - alert on any GPO change 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 Someone changed a GPO - alert on any GPO change. Tell other MSPs how it worked for you.

Write a Review

LanguagePowerShell
Runs onWindows Server 2016+ (DC, or a member with GPMC); runs as SYSTEM
NeedsPowerShell 5.1; admin rights; GroupPolicy module (GPMC); directory change auditing for ChangedBy
Read-onlyReads, changes nothing

What It Does

The script reads every GPO (name, id, modification time, user and computer version numbers) and compares them with a snapshot of the previous run, kept in a small file under the MSP Outpost data folder. It reports Added for a GPO that was not in the snapshot, Removed for one that is gone, and Modified when its time, version numbers or name differ.

The first run only records the snapshot and ends OK. When changes are found it ends ALERT with one row per change and, unless UpdateBaseline is false, moves the snapshot forward, so each change alerts once. ResetBaseline=true records the current state as the new snapshot and ends OK, which is also how you recover from a snapshot that cannot be read.

Reading a GPO does not say who changed it. With FindChangedBy true, the default, the script looks in this computer's Security log for directory change events (5136) on Group Policy objects since the last snapshot and shows the account in ChangedBy. That needs the audit subcategory Audit Directory Service Changes turned on, and it only sees changes made through this domain controller, so run it on the PDC emulator. Otherwise ChangedBy says unknown.

It changes nothing in the domain or on the system. Its only write is its own snapshot file.

Before You Run It

  • Run it on a domain controller, ideally the PDC emulator, or a member server with the Group Policy Management feature (GPMC).
  • Turn on the audit subcategory Audit Directory Service Changes if you want to see who made each change.
  • Run it once to record the baseline before you rely on it as an alert, and run it as the same machine each time.
  • Use ResetBaseline=true after a planned change window so the new state becomes the baseline.

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 30 seconds.
  • Example answer: "2 GPO change(s) since 2026-11-18T09:00:00Z: 1 modified, 1 added, 0 removed; first: Default Domain Policy"
  • Tested before listing on a Windows Server 2025 domain controller (VM) 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.

  • UpdateBaseline: true to record the current state after reporting, so the next run compares with it. Default true.
  • ResetBaseline: true to record the current state and end OK without comparing. Default false.
  • FindChangedBy: true to look up the changing account in the Security log. Default true.

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-gpo-changes.ps1 · 909 lines · 46.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.