← ALL SCRIPTS PowerShell · 2 scripts · Safe-by-default

ADCleanUP

A two-script Active Directory account-hygiene toolkit — CleanUp-ADUsers.ps1 for inactive user accounts and CleanUp-Workstations.ps1 for stale workstation (computer) accounts. Both follow the same inactivity-driven Report → Disable → Delete lifecycle and the same -WhatIf dry-run discipline.

ADCleanUP is a small toolkit for keeping Active Directory free of dormant objects. Both scripts share one philosophy: an inactivity-driven lifecycle that reports first, disables next, and only deletes after a grace period — with a -WhatIf dry-run that produces every report, log and audit row without changing anything, and a deep set of built-in exclusions that keep automation away from accounts that must never be touched.

CleanUp-ADUsers.ps1 handles inactive user accounts. It reports users idle past a reporting threshold, disables them once on-prem inactivity crosses the disable threshold, and deletes them only when a dual gate is satisfied — disabled long enough and genuinely inactive. It can optionally verify each candidate against Microsoft Entra ID sign-in activity before disabling, so hybrid and cloud-only authenticators are not caught by a stale on-prem timestamp. The disable date is stamped into the account’s Notes attribute, and a configurable per-account opt-out — any attribute or any group, validated against the directory at startup — lets you exempt individual accounts.

CleanUp-Workstations.ps1 is the companion script for stale workstation (computer) accounts, applying the same staged, inactivity-driven, safe-by-default cleanup to domain-joined computers whose accounts have gone dormant. Full per-script parameter details are documented in the repository.

What the toolkit does
  • Inactivity-driven Report stage (no changes)
  • Disable stage past the inactivity threshold
  • Delete stage after a post-disable grace period
  • -WhatIf dry-run previews every action
  • CleanUp-ADUsers: optional Entra ID sign-in check
  • CleanUp-ADUsers: stamps disable date into Notes
  • CleanUp-ADUsers: attribute/group opt-out, validated
  • CleanUp-Workstations: stale computer-account sweep
  • Built-in protection for critical accounts
  • Excludes service / krbtgt / gMSA / built-in
  • Timestamped CSV reports per run
  • Per-decision audit CSV trail
  • Structured run log + full transcript
  • HTML summary email with reports attached
PowerShell 5.1+ RSAT-AD 2 scripts Report -> Disable -> Delete -WhatIf dry-run Entra ID (optional) HTML + CSV SupportsShouldProcess
Get Scripts on GitHub

Opens github.com/rt109048/ADCleanUP in a new tab — contains CleanUp-ADUsers.ps1 and CleanUp-Workstations.ps1

Get in touch

Let’s talk identity.

Open to advisory, contract and permanent opportunities involving Active Directory, Entra ID, identity governance, or zero-trust programmes. The best way to reach me is by email.

Location
United States — Remote