Skip to content
Sponsor
3.0 preview2.3.0 stable

These docs describe the preview. Pick the version you run and every page marks what it doesn't have yet. Get the preview →
Maester 2.x docs (archived) →

Add-MtReportAttachment

Embeds an HTML report from another tool, or data for a built-in report view, in the Maester HTML report.

Add-MtReportAttachment -Name <String> -Path <String> [-ContentType <String>]
[-ProgressAction <ActionPreference>] [<CommonParameters>]
Add-MtReportAttachment -Name <String> -Content <String> [-ContentType <String>]
[-ProgressAction <ActionPreference>] [<CommonParameters>]

Call this from a test, an instance source or a pack when the tool it runs writes its own single-file HTML report (for example the Microsoft Zero Trust Assessment). The file is read at once, so the tool’s output folder can be deleted afterwards.

The HTML report shows a button for each HTML attachment on the overview page, and on the result of the test that added it. The button shows the attached report inside the Maester report, beside its navigation, with an option to open it in a new browser tab. The report is stored compressed (gzip, then Base64), so a 10 MB report adds about 2 MB to the Maester report.

With -ContentType application/json the attachment is data that a built-in view of the report reads, found by its Name (for example ‘zero-trust-workshop’, the Zero Trust plan of the Zero Trust Assessment pack). A JSON attachment is not shown as a button. It is stored compressed in the same way.

Attachments are kept only in the HTML report and the results that Invoke-Maester -PassThru returns. The JSON results file lists each attachment’s name and size without its content. When -RedactUserIdentity is used, the HTML report redacts JSON attachments the way it redacts the results, and leaves HTML attachments out, because Maester cannot redact another tool’s report.

The attached page runs in a sandboxed frame, with its scripts in an origin of their own, so it cannot read or change the Maester report or its data. Adding a second attachment with the same name from the same test replaces the first.

Add-MtReportAttachment -Name 'Zero Trust Assessment' -Path ./zt/ZeroTrustAssessmentReport.html

Embeds the Zero Trust Assessment report in the Maester report of this run.

Add-MtReportAttachment -Name 'Tenant inventory' -Content $html

Embeds an HTML page built in memory.

Add-MtReportAttachment -Name 'zero-trust-workshop' -Content $json -ContentType 'application/json'

Adds data for the report’s Zero Trust plan view.

The label of the button that opens the attachment, for example ‘Zero Trust Assessment’. For a JSON attachment, the name the report view reads it by, for example ‘zero-trust-workshop’.

Type: String
Parameter Sets: (All)
Aliases:
Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

Path of a single-file HTML report to embed.

Type: String
Parameter Sets: Path
Aliases:
Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

The HTML or JSON to embed, when it is not in a file.

Type: String
Parameter Sets: Content
Aliases:
Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

text/html (the default) for a report the user opens from a button; application/json for data that a built-in view of the report reads.

Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: Text/html
Accept pipeline input: False
Accept wildcard characters: False

Determines how PowerShell responds to progress updates generated by a script, cmdlet, or provider, such as the progress bars generated by Write-Progress.

Type: ActionPreference
Parameter Sets: (All)
Aliases: proga
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.

https://maester.dev/docs/commands/Add-MtReportAttachment