Add-MtTestResultDetail
SYNOPSIS
Section titled “SYNOPSIS”Add detailed information about a test so that it can be displayed in the test results report.
SYNTAX
Section titled “SYNTAX”Add-MtTestResultDetail [[-Description] <String>] [[-Result] <String>] [[-GraphObjects] <Object[]>] [[-GraphObjectType] <String>] [[-TestName] <String>] [[-TestTitle] <String>] [[-SkippedBecause] <String>] [[-SkippedCustomReason] <String>] [-Investigate] [[-SkippedError] <Object>] [[-Severity] <String>] [-ProgressAction <ActionPreference>] [<CommonParameters>]DESCRIPTION
Section titled “DESCRIPTION”This function is used to add detailed information about a test so that it can be displayed in the test results report.
The description and result support markdown format.
If the calling script/cmdlet has a markdown file with the same name as the script/cmdlet, it will be used to populate the description and result fields.
A good example is the markdown for the Test-MtCaEmergencyAccessExists cmdlet:
- https://github.com/maester365/maester/blob/main/powershell/public/Test-MtCaEmergencyAccessExists.md
- https://github.com/maester365/maester/blob/main/powershell/public/Test-MtCaEmergencyAccessExists.ps1
The markdown file can include a separator <!--- Results ---> to split the description and result sections.
This allows for the overview and detailed information to be displayed separately in the Test results.
EXAMPLES
Section titled “EXAMPLES”EXAMPLE 1
Section titled “EXAMPLE 1”Add-MtTestResultDetail -Description 'Test description' -Result 'Test result'This example adds detailed information about a test with a brief description and the result of the test.
$policiesWithoutEmergency = $policies | Where-Object { $CheckId -notin $_.conditions.users.excludeUsers -and $CheckId -notin $_.conditions.users.excludeGroups }
Add-MtTestResultDetail -GraphObjects $policiesWithoutEmergency -GraphObjectType ConditionalAccessThis example shows how to use the Add-MtTestResultDetail function to add rich markdown content to the test results with deep links to the admin portal.
EXAMPLE 2
Section titled “EXAMPLE 2”Add-MtTestResultDetail -Description 'Check for stale credentials' -Result 'Found 3 service principals with unused credentials' -InvestigateThis example marks a test as requiring investigation. The test passed but needs manual review to confirm all scenarios were considered.
PARAMETERS
Section titled “PARAMETERS”-Description
Section titled “-Description”Brief description of what this test is checking. Markdown is supported.
Type: StringParameter Sets: (All)Aliases:
Required: FalsePosition: 1Default value: NoneAccept pipeline input: FalseAccept wildcard characters: False-Result
Section titled “-Result”Detailed information of the test result to provide additional context to the user. This can be a summary of the items that caused the test to fail (e.g. list of user names, Conditional Access policies, etc.). Markdown is supported. If the test result contains a placeholder %TestResult%, it will be replaced with the values from the $GraphResult
Type: StringParameter Sets: (All)Aliases:
Required: FalsePosition: 2Default value: NoneAccept pipeline input: FalseAccept wildcard characters: False-GraphObjects
Section titled “-GraphObjects”Collection of Graph objects to display in the test results report. This will be inserted into the contents of Result parameter if the result contains a placeholder %TestResult%.
Type: Object[]Parameter Sets: (All)Aliases:
Required: FalsePosition: 3Default value: NoneAccept pipeline input: FalseAccept wildcard characters: False-GraphObjectType
Section titled “-GraphObjectType”The type of graph object, this will be used to show the right deep-link to the test results report.
Type: StringParameter Sets: (All)Aliases:
Required: FalsePosition: 4Default value: NoneAccept pipeline input: FalseAccept wildcard characters: False-TestName
Section titled “-TestName”Pester test name Use the test name from the Pester context by default
Type: StringParameter Sets: (All)Aliases:
Required: FalsePosition: 5Default value: $____Pester.CurrentTest.ExpandedNameAccept pipeline input: FalseAccept wildcard characters: False-TestTitle
Section titled “-TestTitle”A custom title for the test in the format of “MT.XXXX: <TestName>. Used in data driven tests like Entra recommendations 1024”
Type: StringParameter Sets: (All)Aliases:
Required: FalsePosition: 6Default value: NoneAccept pipeline input: FalseAccept wildcard characters: False-SkippedBecause
Section titled “-SkippedBecause”Common reasons for why the test was skipped.
Type: StringParameter Sets: (All)Aliases:
Required: FalsePosition: 7Default value: NoneAccept pipeline input: FalseAccept wildcard characters: False-SkippedCustomReason
Section titled “-SkippedCustomReason”A custom reason for why the test was skipped.
Requires -SkippedBecause Custom.
Type: StringParameter Sets: (All)Aliases:
Required: FalsePosition: 8Default value: NoneAccept pipeline input: FalseAccept wildcard characters: False-Investigate
Section titled “-Investigate”Marks the test as requiring investigation. The test passed but needs manual review to confirm all scenarios were considered. This is different from skipped - the test ran and collected data, but the result needs human interpretation.
Type: SwitchParameterParameter Sets: (All)Aliases:
Required: FalsePosition: NamedDefault value: FalseAccept pipeline input: FalseAccept wildcard characters: False-SkippedError
Section titled “-SkippedError”The error object that caused the test to be skipped.
Type: ObjectParameter Sets: (All)Aliases:
Required: FalsePosition: 9Default value: NoneAccept pipeline input: FalseAccept wildcard characters: False-Severity
Section titled “-Severity”Severity level of the test result. Leave empty if no Severity is defined yet.
Type: StringParameter Sets: (All)Aliases:
Required: FalsePosition: 10Default 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.