New-MtTest
Synopsis
Section titled “Synopsis”Creates a new Maester native test: Test.<ID>.ps1 and Test.<ID>.md.
Syntax
Section titled “Syntax”New-MtTest [-Id] <String> -Title <String> [-Severity <String>] [-Service <String[]>] [-Product <String>] [-Feature <String>] [-Area <String>] [-ResourceType <String>] [-UserImpact <String>] [-ImplementationCost <String>] [-Mitre <String[]>] [-Path <String>] [-Force] [-ProgressAction <ActionPreference>] [-WhatIf] [-Confirm] [<CommonParameters>]Description
Section titled “Description”Writes a test function with its [MaesterTest] attribute and a Markdown file with the description, remediation and result sections. Run it with Invoke-MtTest -Path, and validate it with Get-MtTest -Path.
A custom test needs only an ID and a title. -Product, -Feature, -Area, -ResourceType, -UserImpact, -ImplementationCost and -Mitre fill in the attributes that say what the test is about, what to fix first and which attack techniques it addresses; add or change them in the file later as you like.
Examples
Section titled “Examples”Example 1
Section titled “Example 1”New-MtTest -Id CONTOSO.1001 -Title 'Guest invitations are restricted' -Service Graph -Severity HighCreates custom/Test.CONTOSO.1001.ps1 and custom/Test.CONTOSO.1001.md.
Example 2
Section titled “Example 2”New-MtTest -Id CONTOSO.1002 -Title 'Legacy authentication is blocked' -Product entra -Feature conditional-access -Area authentication -ResourceType Tenant -Severity High -UserImpact Medium -ImplementationCost Low -Mitre T1110.003Creates a test with the classification, priority and ATT&CK attributes filled in. The attribute rubric at https://maester.dev/docs/writing-tests/attribute-rubric explains how to choose each value.
Parameters
Section titled “Parameters”The test ID. Use your own prefix, for example CONTOSO.1001.
Type: StringParameter Sets: (All)Aliases:
Required: TruePosition: 1Default value: NoneAccept pipeline input: FalseAccept wildcard characters: False-Title
Section titled “-Title”The one-line title shown in the report.
Type: StringParameter Sets: (All)Aliases:
Required: TruePosition: NamedDefault value: NoneAccept pipeline input: FalseAccept wildcard characters: False-Severity
Section titled “-Severity”Critical, High, Medium, Low or Info.
Type: StringParameter Sets: (All)Aliases:
Required: FalsePosition: NamedDefault value: MediumAccept pipeline input: FalseAccept wildcard characters: False-Service
Section titled “-Service”The services the test needs, for example Graph or ExchangeOnline.
Type: String[]Parameter Sets: (All)Aliases:
Required: FalsePosition: NamedDefault value: @('Graph')Accept pipeline input: FalseAccept wildcard characters: False-Product
Section titled “-Product”The product where the fix is made: a key of the Maester taxonomy such as entra or exchange (an alias such as ‘Entra ID’ is written as the key), or any name of your own. Groups the console progress and the run summary.
Type: StringParameter Sets: (All)Aliases:
Required: FalsePosition: NamedDefault value: NoneAccept pipeline input: FalseAccept wildcard characters: False-Feature
Section titled “-Feature”The part of the product the test is about, for example conditional-access. With a Maester product, one of its feature keys; otherwise any text.
Type: StringParameter Sets: (All)Aliases:
Required: FalsePosition: NamedDefault value: NoneAccept pipeline input: FalseAccept wildcard characters: FalseThe security theme, for example authentication or privileged-access.
Type: StringParameter Sets: (All)Aliases:
Required: FalsePosition: NamedDefault value: NoneAccept pipeline input: FalseAccept wildcard characters: False-ResourceType
Section titled “-ResourceType”What a failing result points at, for example Tenant or User.
Type: StringParameter Sets: (All)Aliases:
Required: FalsePosition: NamedDefault value: NoneAccept pipeline input: FalseAccept wildcard characters: False-UserImpact
Section titled “-UserImpact”How much the recommended fix disrupts end users: Low, Medium or High.
Type: StringParameter Sets: (All)Aliases:
Required: FalsePosition: NamedDefault value: NoneAccept pipeline input: FalseAccept wildcard characters: False-ImplementationCost
Section titled “-ImplementationCost”How much administrator work the recommended fix takes: Low, Medium or High.
Type: StringParameter Sets: (All)Aliases:
Required: FalsePosition: NamedDefault value: NoneAccept pipeline input: FalseAccept wildcard characters: False-Mitre
Section titled “-Mitre”The MITRE ATT&CK technique IDs the checked control prevents or detects, for example T1110.003, or None.
Type: String[]Parameter Sets: (All)Aliases:
Required: FalsePosition: NamedDefault value: NoneAccept pipeline input: FalseAccept wildcard characters: FalseThe folder to create the files in. Defaults to ./custom (an existing ./Custom folder is reused).
Type: StringParameter Sets: (All)Aliases:
Required: FalsePosition: NamedDefault value: ./customAccept pipeline input: FalseAccept wildcard characters: False-Force
Section titled “-Force”Overwrites existing files.
Type: SwitchParameterParameter Sets: (All)Aliases:
Required: FalsePosition: NamedDefault value: FalseAccept pipeline input: FalseAccept wildcard characters: False-WhatIf
Section titled “-WhatIf”Shows what would happen if the cmdlet runs. The cmdlet is not run.
Type: SwitchParameterParameter Sets: (All)Aliases: wi
Required: FalsePosition: NamedDefault value: NoneAccept pipeline input: FalseAccept wildcard characters: False-Confirm
Section titled “-Confirm”Prompts you for confirmation before running the cmdlet.
Type: SwitchParameterParameter Sets: (All)Aliases: cf
Required: FalsePosition: NamedDefault value: NoneAccept pipeline input: FalseAccept wildcard characters: False-ProgressAction
Section titled “-ProgressAction”Determines how PowerShell responds to progress updates generated by a script, cmdlet, or provider, such as the progress bars generated by Write-Progress.
Type: ActionPreferenceParameter Sets: (All)Aliases: proga
Required: FalsePosition: NamedDefault value: NoneAccept pipeline input: FalseAccept wildcard characters: FalseCommonParameters
Section titled “CommonParameters”This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.