# Preview service-account cleanup

Preview service-account cleanup on Evotec with practical examples, usage guidance, and reusable project workflows.

Project

CleanupMonster

This module provides an easy way to cleanup Active Directory from dead/old objects based on various criteria. It can also disable, move or delete objects. It can utilize Azure AD, Intune and Jamf to get additional information about objects before deleting them.

[View on GitHub](https://github.com/EvotecIT/CleanupMonster) [Visit Website](#) [Releases](https://github.com/EvotecIT/CleanupMonster/releases/tag/v3.1.7) [Changelog](#) [Get package](https://www.powershellgallery.com/packages/CleanupMonster)

Stars**153**

Forks**19**

Open issues**0**

PowerShell Gallery downloads**25686**

Release**v3.1.26**

Language: PowerShell Updated: 2026-11-12

Curated Examples

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

```powershell
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

## Source

- [CleanupServiceAccounts.ps1](https://github.com/EvotecIT/CleanupMonster/blob/master/Examples/CleanupServiceAccounts.ps1)

<!-- PowerForge markdown artifact sha256:AC14247AA12B874CDF5968E7DB8591D786711F2CE6C234316BB3BB9D78AC8F13 -->
