Curated Examples
Preview service-account cleanup
Use CleanupMonster to review managed service account cleanup with low limits.
This pattern is useful when cleaning stale MSA or gMSA objects and you want explicit guardrails.
It is adapted from Examples/CleanupServiceAccounts.ps1.
Example
Import-Module CleanupMonster
$reportPath = Join-Path $PSScriptRoot 'Reports\ServiceAccountsPreview.html'
Invoke-ADServiceAccountsCleanup `
-Disable `
-Delete `
-DisableLastLogonDateMoreThan 90 `
-DeleteLastLogonDateMoreThan 180 `
-DisableLimit 2 `
-DeleteLimit 1 `
-SafetyADLimit 10 `
-IncludeAccounts 'gmsa-*', 'msa-*' `
-ExcludeAccounts 'gmsa-keep-*' `
-ReportOnly `
-WhatIfDisable `
-WhatIfDelete `
-ReportPath $reportPath
What this demonstrates
- separating disable and delete thresholds
- using explicit account filters
- keeping action limits low for review