# Machine account quota should be retrievable

The machine account quota (ms-DS-MachineAccountQuota) attribute controls how many computer accounts a standard (non-administrative) user can join to the…

Source: https://maester.dev/docs/tests/AD-DOM-02

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

```powershell title="Run this check"
Invoke-Maester -TestId AD-DOM-02
```

## Overview

The machine account quota (ms-DS-MachineAccountQuota) attribute controls how many computer accounts a standard (non-administrative) user can join to the domain. The default value of 10 can create security risks:

- **Rogue Computer Joins**: Attackers with valid user credentials can join unauthorized computers to the domain
- **Lateral Movement**: Joined computers can be used as pivot points for further attacks
- **Resource Exhaustion**: Excessive computer accounts can clutter the directory and complicate management

#### Control Type

**Preventive**

#### Security Recommendation

Consider reducing the machine account quota to 0 and using alternative methods for computer joins:

1. **Set quota to 0**: Prevents standard users from joining computers
2. **Use pre-staged accounts**: Administrators create computer accounts in advance
3. **Delegate join permissions**: Grant specific groups permission to join computers
4. **Implement privileged access workstations**: Use dedicated admin workstations for domain joins

To modify the quota:
```powershell
Set-ADDomain -Identity "yourdomain.com" -Replace @{"ms-DS-MachineAccountQuota"="0"}
```

#### How the Test Works

This test retrieves the current machine account quota value from Active Directory. The test is informational and helps you assess whether the default value poses a risk in your environment.

#### Related Tests

- `Test-MtAdDomainFunctionalLevel` - Retrieves the domain functional level
- `Test-MtAdDomainControllerCount` - Counts domain controllers

#### Related links

- [Microsoft Defender for Identity: Resolve unsecure domain configurations](https://learn.microsoft.com/defender-for-identity/security-posture-assessments/identity-infrastructure#resolve-unsecure-domain-configurations)
- [ANSSI Active Directory checkpoints: Unrestricted domain join](https://www.cert.ssi.gouv.fr/uploads/ad_checklist.html#vuln_user_accounts_machineaccountquota)

## Details

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

| Field | Value |
| --- | --- |
| Test ID | AD-DOM-02 |
| Severity | Info |
| Suite | Active Directory |
| Product | Active Directory |
| Feature | Domain and forest |
| Area | Access control |
| Resource type | Tenant |
| MITRE ATT&CK | T1136.002 Domain Account |
| PowerShell test | [Test-MtAdMachineAccountQuota](https://github.com/maester365/maester/blob/main/tests/ad/domain/Test.AD-DOM-02.ps1) |
| Services | ActiveDirectory |
| Permissions | ActiveDirectory:Ldap:domainDNS.ms-DS-MachineAccountQuota:ReadProperty |

</details>

## Source

- Test: [`tests/ad/domain/Test.AD-DOM-02.ps1`](https://github.com/maester365/maester/blob/main/tests/ad/domain/Test.AD-DOM-02.ps1)
- Documentation: [`tests/ad/domain/Test.AD-DOM-02.md`](https://github.com/maester365/maester/blob/main/tests/ad/domain/Test.AD-DOM-02.md)
