Test builder
Who is the test for?
Every Maester test declares what it is about, how urgent a failure is and what it needs to run, in a [MaesterTest()] attribute. Pick the values step by step and the code updates as you go. The help button beside a field says what it means, what happens when you leave it empty, and the rule reviewers apply.
Want an AI assistant to write the test? Fill in what you know, then open . How it works.
Name it
IDs start with MT. or MT1060. or AZDO.. Files go in tests/maester.
What is it about?
How an identity proves who it is: MFA, authentication methods, passwords, legacy protocols, Kerberos and NTLM hardening, session and token lifetime.
A tenant-, organization-, forest- or domain-wide setting. The result is about the environment, not a list of objects.
What should be fixed first?
A primary control is missing or weakened for many users or for privileged identities, and common techniques such as phishing, password spray or consent phishing are enough to use it.
End users notice nothing, or only administrators are affected.
One setting or one policy in one portal. Under an hour, with no dependency on another team, a licence purchase or a rollout.
What does it map to?
Which service connections does it need?
Which licences does the tenant need?
A test requires service plans, the building blocks inside a product such as Microsoft 365 E5. Plans inside one box are joined with and: the tenant needs all of them. Boxes are joined with or: any one box is enough.
- AAD_PREMIUM · Maester also counts its government and education variants
The test runs when the tenant has AAD_PREMIUM. Otherwise it is skipped.
Which permissions does it need?
Each box is one thing the test needs, and the test needs all of them. Permissions inside one box are alternatives: any one of them is enough. Put the least privileged one first.
Graph:Scope:Policy.Read.All· A Microsoft Graph permission that works as a delegated or an application permission.
The identity Maester signs in with needs Policy.Read.All. Maester records this on the result; it does not skip the test on it yet.
Where does it apply?
Leave these empty unless the test is only valid in some tenants, clouds or operating systems. Most tests leave them empty.
What can an administrator change?
A parameter is a value of this test that an administrator can change in maester-config.json, such as a threshold or a list of exceptions.
A shared setting is one value that many tests use: a fact about the tenant, or a choice the organization makes once, such as its emergency access accounts or the domains that never send email. The administrator sets it once under GlobalSettings and every test that binds a parameter to it receives it. The help button explains how to add a new one.
Lifecycle and credit
@your-github-handle
Write it with AI
An AI coding assistant such as GitHub Copilot or Claude Code can write the test from a prompt. The prompt below carries the values you picked in the steps, points the assistant at Maester's guides and tells it how to check its work. The ID and the title are enough to start; every other value you pick is one less for it to guess.
Run it in a clone of the Maester repository, which has agents and skills for writing a check. How this works, and how to check the result.
Copy this into your assistant.
I want to add a security check to Maester. Work in my clone of https://github.com/maester365/maester.
What the check should verify:
<Describe the setting to check, the value you expect and why it matters.>
Follow the repository's own guidance before you write anything:
- AGENTS.md
- the maester-test-expert skill: .github/skills/maester-test-expert/SKILL.md
- website/docs/writing-tests/index.mdx
- website/docs/writing-tests/attribute-rubric.md
Steps:
1. Look for a test that already checks this setting, in every suite (Get-MtTest -Product entra -Feature conditional-access, and a search of tests/ for the setting or endpoint). If one exists, stop and tell me.
2. Create ./tests/maester/entra/Test.MT.1234.ps1 and ./tests/maester/entra/Test.MT.1234.md. Start from the code below, which I made in the test builder at https://maester.dev/test-builder. Check each attribute value against the rubric and tell me which you would change and why.
3. Write the function body. Read the tenant through Maester's helpers and the session cache, declare Service and License instead of checking connections or licences in code, use no outer try/catch, return $true or $false, and report with Add-MtTestResultDetail. Give the function a name that says what it checks.
4. Write the .md: what is checked and why it matters, numbered remediation steps with a direct link to the admin portal page, and the Microsoft Learn article.
5. Validate: Get-MtTest MT.1234, regenerate the golden fixture (./build/golden/Export-MtGoldenFixture.ps1), git add the new files, then run ./powershell/tests/pester.ps1 and fix what it flags.
Do not commit, push or open a pull request until I have reviewed the files. The ID MT.1234 must be reserved on https://github.com/maester365/maester/issues/697 first; remind me if I have not said it is.
Test.MT.1234.ps1:
function Test-MT1234 {
<#
.SYNOPSIS
At least one Conditional Access policy blocks device code flow.
.DESCRIPTION
Describe the control and what the check evaluates.
#>
[MaesterTest(
Id = 'MT.1234',
Title = 'At least one Conditional Access policy blocks device code flow.',
Product = 'entra',
Feature = 'conditional-access',
Area = 'authentication',
ResourceType = 'Tenant',
Severity = 'High',
UserImpact = 'Low',
ImplementationCost = 'Low',
Mitre = ('T1078.004', 'T1528', 'T1566'),
Service = 'Graph',
License = 'AAD_PREMIUM',
Permission = 'Graph:Scope:Policy.Read.All',
Author = 'your-github-handle'
)]
[CmdletBinding()]
[OutputType([bool])]
param()
# Read the tenant state. The engine has already checked that the services above are connected,
# and turns an uncaught error into an Error result, so no connection check or try/catch is needed.
$settings = Invoke-MtGraphRequest -RelativeUri 'policies/authorizationPolicy'
$passed = $null -ne $settings
$resultMarkdown = if ($passed) { 'Well done. The tenant meets this requirement.' } else { 'The tenant does not meet this requirement.' }
Add-MtTestResultDetail -Result $resultMarkdown
return $passed
}
Read what the assistant writes before you run it: check the endpoint and property names against Microsoft Learn, and run the test on a tenant you know.