# Known service account count should be retrievable

Many environments use recognizable naming conventions for service accounts such as svc, service, or _svc.

Source: https://maester.dev/docs/tests/AD-USER-20

<!-- This file is generated by website/scripts/generate-test-docs.mjs. Do not edit manually. -->

<div class="test-byline"><div class="test-byline-avatars"><a class="test-byline-avatar test-byline-avatar--author" href="/contributors/soulemike" title="Michael Soule · Original author"><img src="https://github.com/soulemike.png" alt="Michael Soule" width="28" height="28" loading="lazy" decoding="async" /></a></div><div class="test-byline-meta"><span class="test-byline-text">Contributed by <a href="/contributors/soulemike">Michael Soule</a></span><a class="test-byline-link" href="/contributors">All contributors →</a></div></div>

<p class="test-part">Part of <a href="/docs/tests/ad">Active Directory</a> · Active Directory · Users · <a href="/docs/tests">All checks</a></p>

```powershell title="Run this check"
Invoke-Maester -TestId AD-USER-20
```

## Overview

Many environments use recognizable naming conventions for service accounts such as `svc_`, `service_`, or `_svc`. These patterns make service accounts easier to inventory and harden.

- **Service account inventory**: Helps locate likely service identities quickly
- **Hardening prioritization**: Supports focused review of passwords, SPNs, and delegation
- **Monitoring alignment**: Makes it easier to target logon, privilege, and usage monitoring

#### Control Type

**Detective**

#### Security Recommendation

- Review accounts matching known service account naming patterns for proper ownership and documentation
- Apply stronger controls to service accounts, including long random passwords and interactive logon restrictions
- Prefer managed service account options where the workload supports them

#### How the Test Works

This test counts user objects whose `SamAccountName` or `Name` matches common service account naming patterns such as `svc_`, `service_`, `_svc`, `sa_`, and similar variants.

#### Related Tests

- `Test-MtAdUserSpnSetCount` - Identifies service accounts through SPN usage
- `Test-MtAdUserAdminCountCount` - Highlights service accounts that may also be protected or privileged

## Details

<details>
<summary>Every attribute of this check</summary>

| Field | Value |
| --- | --- |
| Test ID | AD-USER-20 |
| Severity | Info |
| Suite | Active Directory |
| Product | Active Directory |
| Feature | Users |
| Area | Applications and workload identities |
| Resource type | User |
| MITRE ATT&CK | None |
| PowerShell test | [Test-MtAdUserKnownServiceAccountCount](https://github.com/maester365/maester/blob/main/tests/ad/user/Test.AD-USER-20.ps1) |
| Services | ActiveDirectory |
| Permissions | ActiveDirectory:Ldap:user:ReadProperty |

</details>

## Source

- Test: [`tests/ad/user/Test.AD-USER-20.ps1`](https://github.com/maester365/maester/blob/main/tests/ad/user/Test.AD-USER-20.ps1)
- Documentation: [`tests/ad/user/Test.AD-USER-20.md`](https://github.com/maester365/maester/blob/main/tests/ad/user/Test.AD-USER-20.md)
