# Managed service account count should be investigated

Security Benefits: - Automatic Password Rotation: Passwords change automatically (every 30 days for gMSAs) - Eliminates Manual Management: No need for…

Source: https://maester.dev/docs/tests/AD-MSA-01

<!-- 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 · Account security · <a href="/docs/tests">All checks</a></p>

```powershell title="Run this check"
Invoke-Maester -TestId AD-MSA-01
```

## Overview

- Managed Service Accounts (MSAs) and Group Managed Service Accounts (gMSAs) provide significant security improvements over traditional service accounts by automating password management and simplifying service principal name (SPN) management.

**Security Benefits:**
- **Automatic Password Rotation**: Passwords change automatically (every 30 days for gMSAs)
- **Eliminates Manual Management**: No need for administrators to manage service account passwords
- **No Interactive Logon**: Cannot be used for interactive logon, reducing attack surface
- **Reduced Credential Theft Risk**: Passwords are complex and regularly changed
- **Simplified Administration**: No manual password changes or coordination required

**Types of Managed Service Accounts:**
- **Standalone MSA**: For use on a single computer (legacy, largely replaced by gMSA)
- **Group MSA (gMSA)**: Can be used across multiple computers, preferred solution

#### Control Type

**Operational**

#### Security Recommendation

1. **Use gMSAs Where Possible**:
   - Replace traditional service accounts with gMSAs
   - Prioritize high-privilege service accounts
   - Plan migration for legacy applications

2. **Implementation Requirements**:
   - At least one Windows Server 2012 or later domain controller
   - KDS root key must be created (one-time operation)
   - Applications must support gMSA authentication

3. **Best Practices**:
   - Use gMSAs for all new service deployments
   - Create separate gMSAs for different services
   - Document gMSA usage and permissions
   - Regular audit of gMSA deployments

#### How the Test Works

This test counts managed service accounts in Active Directory and categorizes them by:
- Total MSAs and gMSAs
- Group vs. standalone MSAs
- Account details and status

#### Related Tests

- `Test-MtAdUserKnownServiceAccountCount` - Traditional service account identification
- `Test-MtAdKdsRootKeysCount` - KDS root key requirement for gMSAs
- `Test-MtAdUserPasswordNeverExpiresCount` - Traditional accounts with non-expiring passwords

#### References

- [Microsoft: Group Managed Service Accounts Overview](https://docs.microsoft.com/windows-server/security/group-managed-service-accounts/group-managed-service-accounts-overview)
- [Microsoft: Getting Started with gMSAs](https://docs.microsoft.com/windows-server/security/group-managed-service-accounts/getting-started-with-group-managed-service-accounts)

## Details

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

| Field | Value |
| --- | --- |
| Test ID | AD-MSA-01 |
| Severity | Info |
| Suite | Active Directory |
| Product | Active Directory |
| Feature | Account security |
| Area | Applications and workload identities |
| Resource type | Tenant |
| MITRE ATT&CK | None |
| PowerShell test | [Test-MtAdManagedServiceAccountCount](https://github.com/maester365/maester/blob/main/tests/ad/security/Test.AD-MSA-01.ps1) |
| Services | ActiveDirectory |
| Permissions | ActiveDirectory:Ldap:msDS-GroupManagedServiceAccount:ReadProperty |

</details>

## Source

- Test: [`tests/ad/security/Test.AD-MSA-01.ps1`](https://github.com/maester365/maester/blob/main/tests/ad/security/Test.AD-MSA-01.ps1)
- Documentation: [`tests/ad/security/Test.AD-MSA-01.md`](https://github.com/maester365/maester/blob/main/tests/ad/security/Test.AD-MSA-01.md)
