Add-MtAffectedObjectFact
Synopsis
Section titled “Synopsis”Adds facts about an object, such as its last sign-in or its expired secrets, to the Affected objects page.
Syntax
Section titled “Syntax”Add-MtAffectedObjectFact [-Type] <String> [-Id] <String> [-Fact] <Object[]> [[-System] <String>] [-Source] <String> [[-AsOf] <DateTime>] [-ProgressAction <ActionPreference>] [<CommonParameters>]Description
Section titled “Description”Call this from a test, an instance source or a pack that knows more about an object than the checks that name it: when the object was last used, which permissions it holds, whether its credentials have expired. The facts are shown with the object on the Affected objects page of the HTML report and kept in the AffectedObjects of the results, the JSON output and the objects files.
Add-MtTestResultDetail -GraphObjects says which objects a result is about, and adds them to the page with the check that named them. Add-MtAffectedObjectFact says what is known about an object, whichever check named it.
Facts only describe an object that the run already lists. They are merged into the record with the same System, Type and Id when the results are built, so adding facts about an object that no check names adds nothing to the report. Facts are collected only while Invoke-Maester collects affected objects; otherwise the call does nothing.
Each fact has a Name, a Value and a Tone: Risk for something to fix, Warning for something to review, Good for a sign that the object is in order, and Info (the default) for anything else.
A fact can also carry a Key and a Raw value, for code that reads the results: a summary, an insight or another report. The Key names what the fact is about, from the shared list of fact keys (user.mfaRegistered, signIn.daysSince, device.managed…), so the same fact from two sources means the same thing. Raw is its value as data: a boolean, a number, a string, a list of strings or a date, which is kept as an ISO 8601 UTC string. Value stays the text people read. Raw is kept only with a Key. A fact without a Key is shown the same way.
Adding a fact with the same Key, or without a Key the same Name, from the same Source again replaces the earlier one.
The value is shown as text. Name counts rather than other people where you can: the page shows facts to everyone who reads the report, and -RedactUserIdentity replaces only the names of users the run knows.
Examples
Section titled “Examples”Example 1
Section titled “Example 1”Add-MtAffectedObjectFact -Type ServicePrincipal -Id $sp.id -Source 'Contoso inventory' -Fact @( @{ Name = 'Last sign-in'; Value = '2026-06-15 (143 days ago)'; Tone = 'Risk' } @{ Name = 'Publisher'; Value = 'Third party (Contoso Ltd)' })Adds two facts to an enterprise application.
Example 2
Section titled “Example 2”Add-MtAffectedObjectFact -Type User -Id $user.id -Source 'Contoso HR' -Fact @( @{ Name = 'MFA'; Value = 'Not registered'; Tone = 'Risk'; Key = 'user.mfaRegistered'; Raw = $false } @{ Name = 'Last sign-in'; Value = '2026-06-15 (143 days ago)'; Tone = 'Warning'; Key = 'signIn.daysSince'; Raw = 143 })Adds facts with keys, so code can read whether the user has MFA and how long since they signed in without parsing the text.
Example 3
Section titled “Example 3”$records | Add-MtAffectedObjectFact -Source 'Zero Trust Assessment' -AsOf $report.ExecutedAtAdds facts to many objects at once. Each record has Type, Id and Fact properties, and optionally System.
Parameters
Section titled “Parameters”The object type, as the Affected objects page records it: User, Group, ServicePrincipal, AppRegistration (keyed by its appId), Device, ConditionalAccessPolicy, AgentIdentity, AgentIdentityBlueprint, ConfigurationPolicy…
Type: StringParameter Sets: (All)Aliases:
Required: TruePosition: 1Default value: NoneAccept pipeline input: True (ByPropertyName)Accept wildcard characters: FalseThe object’s id, the same id the record uses (for an app registration, its appId).
Type: StringParameter Sets: (All)Aliases:
Required: TruePosition: 2Default value: NoneAccept pipeline input: True (ByPropertyName)Accept wildcard characters: FalseThe facts: hashtables or objects with Name, Value, and optionally Tone (Risk, Warning, Good or Info), Key (a shared fact key such as user.mfaRegistered) and Raw (its value as data).
Type: Object[]Parameter Sets: (All)Aliases:
Required: TruePosition: 3Default value: NoneAccept pipeline input: True (ByPropertyName)Accept wildcard characters: False-System
Section titled “-System”Where the object lives: EntraID (the default), Intune, ExchangeOnline, GitHub…
Type: StringParameter Sets: (All)Aliases:
Required: FalsePosition: 4Default value: EntraIDAccept pipeline input: True (ByPropertyName)Accept wildcard characters: False-Source
Section titled “-Source”What the facts come from, shown with them, for example ‘Zero Trust Assessment’.
Type: StringParameter Sets: (All)Aliases:
Required: TruePosition: 5Default value: NoneAccept pipeline input: FalseAccept wildcard characters: FalseWhen the data behind the facts was read, when that is not now (a report written earlier).
Type: DateTimeParameter Sets: (All)Aliases:
Required: FalsePosition: 6Default 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.
Inputs
Section titled “Inputs”Outputs
Section titled “Outputs”System.Void
Section titled “System.Void”Related links
Section titled “Related links”https://maester.dev/docs/commands/Add-MtAffectedObjectFact
https://maester.dev/docs/writing-tests/formatting-test-results#adding-facts-about-an-object
https://maester.dev/docs/writing-tests/formatting-test-results#fact-keys