# Security group count should be retrievable

Security groups are the foundation of access control in Active Directory. Understanding their count and distribution is critical for:

Source: https://maester.dev/docs/tests/AD-GRP-07

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

```powershell title="Run this check"
Invoke-Maester -TestId AD-GRP-07
```

## Overview

Security groups are the foundation of access control in Active Directory. Understanding their count and distribution is critical for:

- **Access management assessment**: High numbers of security groups may indicate complex or poorly managed permissions
- **Security auditing**: Security groups directly control who can access what resources
- **Privilege analysis**: Helps identify the scale of group-based access control to audit
- **Compliance requirements**: Many frameworks require documentation and regular review of security groups

Security groups can be assigned permissions to resources, unlike distribution groups.

#### Control Type

**Operational**

#### Security Recommendation

Establish governance around security groups:
1. Implement a naming convention for security groups to improve manageability
2. Regularly audit security group memberships, especially for privileged groups
3. Document the purpose and owner of each security group
4. Remove unused or stale security groups to reduce attack surface
5. Consider implementing privileged access management for highly sensitive groups

#### How the Test Works

This test examines all group objects and identifies those where:
- The `GroupCategory` property equals "Security"
- These groups can be assigned permissions and used for access control

The test provides counts and percentages to understand the proportion of security groups versus distribution groups.

#### Related Tests

- `Test-MtAdGroupDistributionCount` - Counts distribution groups (email-only)
- `Test-MtAdGroupDomainLocalCount` - Counts domain local scope groups
- `Test-MtAdGroupGlobalCount` - Counts global scope groups
- `Test-MtAdGroupUniversalCount` - Counts universal scope groups

## Details

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

| Field | Value |
| --- | --- |
| Test ID | AD-GRP-07 |
| Severity | Info |
| Suite | Active Directory |
| Product | Active Directory |
| Feature | Groups |
| Area | Infrastructure hardening |
| Resource type | Group |
| MITRE ATT&CK | None |
| PowerShell test | [Test-MtAdGroupSecurityCount](https://github.com/maester365/maester/blob/main/tests/ad/group/Test.AD-GRP-07.ps1) |
| Services | ActiveDirectory |
| Permissions | ActiveDirectory:Ldap:group:ReadProperty |

</details>

## Source

- Test: [`tests/ad/group/Test.AD-GRP-07.ps1`](https://github.com/maester365/maester/blob/main/tests/ad/group/Test.AD-GRP-07.ps1)
- Documentation: [`tests/ad/group/Test.AD-GRP-07.md`](https://github.com/maester365/maester/blob/main/tests/ad/group/Test.AD-GRP-07.md)
