Test-OfficeAccessibility
Checks Word, Excel and PowerPoint files for accessibility issues. The input is never changed.
Syntax
Test-OfficeAccessibility
[-IncludeWarnings]
[-Password <SecureString>]
[-Path] <String[]>
[-Quiet]
[-Sarif]
[-Strict]
[<CommonParameters>]#PathTest-OfficeAccessibility
[-IncludeWarnings]
-LiteralPath <String[]>
[-Password <SecureString>]
[-Quiet]
[-Sarif]
[-Strict]
[<CommonParameters>]#LiteralPathTest-OfficeAccessibility
-Document <Object>
[-IncludeWarnings]
[-Quiet]
[-Sarif]
[-Strict]
[<CommonParameters>]#DocumentDescription
Runs the rules of the Office Accessibility Checker: alternative text, table header rows, document title and language, headings, hyperlink text, text contrast, slide titles, merged cells, default and hidden sheets, and blank cells or paragraphs used for spacing. All three formats return the same finding codes and severities. Strict turns structural warnings into errors and requires a document title; heuristic findings stay warnings.
Examples
List the accessibility findings of a workbook.
(Test-OfficeAccessibility -Path .\Budget.xlsx).Findings | Format-Table Severity, Code, Location, MessageFail a build when any document in a folder has accessibility errors.
$failed = Get-ChildItem .\Docs -Include *.docx, *.xlsx, *.pptx -Recurse | Test-OfficeAccessibility -Strict -ErrorAction Stop |
Where-Object { -not $_.IsSuccessful }
if ($failed) { throw "Accessibility errors in $($failed.Count) document(s)." }Write a SARIF log for code-scanning tools.
Test-OfficeAccessibility -Path .\Deck.pptx -Sarif | Set-Content .\Deck.sarifParameters
- -IncludeWarnings SwitchParameter
- With Quiet, warnings also make the result false.
- -Password SecureString
- Password for an encrypted path input. Accepts SecureString or PSCredential; plain strings are transformed with a warning.
- -Path String[]
- Files to inspect; supports wildcards.
- -Quiet SwitchParameter
- Returns a Boolean per input: true when there are no errors (and no warnings with IncludeWarnings).
- -Sarif SwitchParameter
- Returns each report as a SARIF 2.1.0 log string instead of a report object.
- -Strict SwitchParameter
- Uses the strict profile: structural warnings become errors and a document title is required.
- -LiteralPath String[]
- Exact file paths, including FileInfo.FullName and provider PSPath pipeline properties.
- -Document Object
- An open Word, Excel or PowerPoint document, including unsaved edits.
Common Parameters
This command supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable.
For more information, see about_CommonParameters.
Outputs
PSWriteOffice.Models.OfficeAccessibilityFileReport: Accessibility findings for one Word, Excel or PowerPoint file or open document.