Three-stage lifecycle for stale Active Directory user and computer accounts — Disable → Move → Delete. Audit-only by default; every stage is opt-in and gated by an explicit -Apply switch. Built-in protection for krbtgt, adminCount=1, DC accounts and the standard privileged groups.
Caller-supplied protection layers on top of the built-ins: -ExcludeGroup (recursive members), -ExcludeOU, -ExcludeName (wildcards). The Disable stage tags the object’s Description with DISABLED-STALE-yyyy-MM-dd so the Delete stage can verify the configurable grace period before removing anything. Every run produces a timestamped HTML report plus per-object Findings and per-action Actions CSVs — nothing is ever deleted from the report folder, so historical runs accumulate. _Latest overwrite copies make a single bookmarked path always reflect the most recent run.
Opens github.com/rt109048/Invoke-ADStaleObjectsCleanup in a new tab
PROVIDED AS IS. Free, open-source utility intended for experienced administrators. Always test in a non-production lab environment before running anywhere that matters. By downloading and running this script you accept full responsibility for the outcome — the author accepts no liability for any direct or indirect damage caused by use, misuse, or modification.
Copyright © 2026 ITC Technology
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
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.