Add-MtReportAttachment
Synopsis
Section titled “Synopsis”Embeds an HTML report from another tool, or data for a built-in report view, in the Maester HTML report.
Syntax
Section titled “Syntax”Path (Default)
Section titled “Path (Default)”Add-MtReportAttachment -Name <String> -Path <String> [-ContentType <String>] [-ProgressAction <ActionPreference>] [<CommonParameters>]Content
Section titled “Content”Add-MtReportAttachment -Name <String> -Content <String> [-ContentType <String>] [-ProgressAction <ActionPreference>] [<CommonParameters>]Description
Section titled “Description”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.
Examples
Section titled “Examples”Example 1
Section titled “Example 1”Add-MtReportAttachment -Name 'Zero Trust Assessment' -Path ./zt/ZeroTrustAssessmentReport.htmlEmbeds the Zero Trust Assessment report in the Maester report of this run.
Example 2
Section titled “Example 2”Add-MtReportAttachment -Name 'Tenant inventory' -Content $htmlEmbeds an HTML page built in memory.
Example 3
Section titled “Example 3”Add-MtReportAttachment -Name 'zero-trust-workshop' -Content $json -ContentType 'application/json'Adds data for the report’s Zero Trust plan view.
Parameters
Section titled “Parameters”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: StringParameter Sets: (All)Aliases:
Required: TruePosition: NamedDefault value: NoneAccept pipeline input: FalseAccept wildcard characters: FalsePath of a single-file HTML report to embed.
Type: StringParameter Sets: PathAliases:
Required: TruePosition: NamedDefault value: NoneAccept pipeline input: FalseAccept wildcard characters: False-Content
Section titled “-Content”The HTML or JSON to embed, when it is not in a file.
Type: StringParameter Sets: ContentAliases:
Required: TruePosition: NamedDefault value: NoneAccept pipeline input: FalseAccept wildcard characters: False-ContentType
Section titled “-ContentType”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: StringParameter Sets: (All)Aliases:
Required: FalsePosition: NamedDefault value: Text/htmlAccept 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.