GP monitor: visar per klient när Group Policy senast körde, vilken DC som svarade och om GPO:erna är i fas. För DC-migreringar med SYSVOL (DFS-R).
  • PowerShell 62%
  • Python 38%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
claude-bot 125bf677c0 DC-säkerhet efter granskning: preflight, opt-in audit, tidsgränser, låsta versioner
- install.ps1 Dc: avbryter om CrashOnAuditFail är på, säkerhetsloggen inte skriver över
  äldsta händelser eller disken saknar plats; frågar innan Detailed File Share slås på
  (-EnableDetailedAudit); uppgifter via XML med tidsgräns, IgnoreNew, låg prioritet
- Send-SysvolAccess: läser nyaste först och stannar vid bokmärket (filtret
  EventRecordID > n gick igenom hela loggen varje körning), max 5000 per körning
- Send-GPOBaseline: portkoll 389/445 per DC, Get-DfsrBacklog i jobb med 60 s gräns
- Server: brandvägg LocalSubnet som standard, exakta paketversioner, CN max 64 tecken
  (mottagaren kraschade vid start med långt FQDN)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-02 06:20:28 +02:00
client GP monitor: HTTPS-mottagare med dashboard, DC-insamlare (SYSVOL-audit, GPO-baseline) och klientrapportör 2026-10-02 05:57:07 +02:00
dc DC-säkerhet efter granskning: preflight, opt-in audit, tidsgränser, låsta versioner 2026-10-02 06:20:28 +02:00
server DC-säkerhet efter granskning: preflight, opt-in audit, tidsgränser, låsta versioner 2026-10-02 06:20:28 +02:00
.gitignore GP monitor: HTTPS-mottagare med dashboard, DC-insamlare (SYSVOL-audit, GPO-baseline) och klientrapportör 2026-10-02 05:57:07 +02:00
install.ps1 DC-säkerhet efter granskning: preflight, opt-in audit, tidsgränser, låsta versioner 2026-10-02 06:20:28 +02:00
README.md DC-säkerhet efter granskning: preflight, opt-in audit, tidsgränser, låsta versioner 2026-10-02 06:20:28 +02:00

GP monitor

Shows, per Windows client, when Group Policy last ran, which DC served it, whether the run had warnings or errors, and whether each GPO was applied at the current version. Built for DC migrations with SYSVOL (DFS-R) replication in flight.

Parts

server/app.py is a FastAPI webhook receiver with a dashboard, stored in SQLite. client/Send-GPReport.ps1 runs on each client as SYSTEM after every GP run (event-triggered on GroupPolicy/Operational 8000/8001/8004/8006/8007) and once a day as a heartbeat. It reads gpresult /x and correlates the run's events by ActivityID to get the DC (event 5308) and any warnings or errors. Reports are spooled locally if the server is unreachable. client/Install-GPReporter.ps1 copies the script to C:\ProgramData\GPReporter, writes the endpoint and token (ACL: SYSTEM and Administrators only), and registers the task. dc/Send-SysvolAccess.ps1 runs on every DC and reports which machines (and users) read which GPOs from SYSVOL, when, and from which DC, using audit event 5145. No client install needed. Requires "Audit Detailed File Share: Success" on the Domain Controllers OU. dc/Send-GPOBaseline.ps1 reads each GPO's AD and SYSVOL version on every DC plus the SYSVOL backlog from the PDC. The server uses this as the reference for "current".

Setup

Run install.ps1 as administrator on each machine, straight from this server:

& ([scriptblock]::Create((irm https://git.dinitkompis.se/claude-bot/gpmon/raw/branch/main/install.ps1))) -Role <Server|Dc|Baseline|Client> [options]

It downloads the repo to a temp folder, installs the role and removes the temp folder. -Ref <commit> installs a fixed version instead of main; use it on DCs so a later push can't change what they run. Without internet, copy the folder over and run powershell -ExecutionPolicy Bypass -File .\install.ps1 ... instead. Run it again to update; add -Uninstall to remove a role. In the steps below, .\install.ps1 stands for either form.

  1. Receiver, once: powershell -ExecutionPolicy Bypass -File .\install.ps1 -Role Server. It needs Python 3.10+ installed for all users (it tries winget if Python is missing). It installs to C:\ProgramData\GPMonitor in a venv, starts at boot as SYSTEM (task GPMonitor), opens TCP 8443 in the firewall, and prints the dashboard URL, token and certificate thumbprint. The port is opened for the local subnet only (the dashboard has no login); add other subnets that DCs or clients report from with -AllowFrom 10.1.0.0/16,10.2.0.0/16. Without internet on the server, download the packages elsewhere and pass -Wheels <folder>: pip download -r server\requirements.txt -d wheels --only-binary=:all: --platform win_amd64 --python-version 3.12
  2. Every DC, old and new: .\install.ps1 -Role Dc -Server https://<receiver>:8443 -CertThumbprint <thumbprint>. It first refuses to install if CrashOnAuditFail is on, the Security log isn't set to overwrite oldest events, or the log disk lacks space. Then it asks for the token, asks before turning on Audit Detailed File Share (Success) (-EnableDetailedAudit skips the question), raises the Security log to 1 GB (-SecurityLogMB, never shrinks it), test-sends once, and schedules Send-SysvolAccess.ps1 every 5 minutes as SYSTEM (max 4 minutes per run, below-normal priority, never two at once). On a DC that is also a file server, the audit setting logs every share access, so use -SecurityLogMB 4096 there. It warns if a GPO controls audit policy or log size and would undo this; then set it in that GPO. -Uninstall switches audit off again only if it was off before.
  3. One DC: .\install.ps1 -Role Baseline -Server ... -CertThumbprint ... schedules Send-GPOBaseline.ps1 every 15 minutes (max 10 minutes per run; a DC that doesn't answer on LDAP/SMB is skipped after 3 seconds, the DFS-R backlog query after 60).
  4. Optional, clients: .\install.ps1 -Role Client -Server ... -CertThumbprint ..., or deploy client\Install-GPReporter.ps1 -Endpoint https://<receiver>:8443/api/report -Token <token> via RMM, a startup script or Intune. To test, run gpupdate /force on a client; a report arrives about 30 seconds later.

The DC scripts can still be run by hand with -Endpoint, -Token and -CertThumbprint.

Notes

The token sits in plain text in the deployment method you choose (for example, startup script parameters in SYSVOL are readable by domain users). It only allows posting reports, but rotate it after the migration. On first rollout, check one client's GPO table against GPMC. gpresult normally reports per-scope version numbers; the server also handles the packed AD value, but it is worth verifying in your environment. Optional settings (environment or settings.env next to run.py): GPMON_DB (default gpmon.db), GPMON_STALE_HOURS (default 26), GPMON_PORT (default 8443).