Test-ConsoleTheme
Checks a theme's text contrast, status colours, markers and critical fill.
Syntax
Description
Checks the active theme, a named preset, or a JSON/PSD1 file without changing settings. Text needs WCAG contrast of 4.5:1 against its own fill or the page background. Pass, warning and fail need CIELAB distance 25 in normal vision and full-severity Machado protanopia, deuteranopia and tritanopia simulations. Markers must differ without colour. Critical may share Fail's hue when it has a distinct fill. The Terminal preset is measured against the startup palette when the terminal answers OSC 4/10/11. Otherwise the actual colours of palette indexes, terminal-default text and terminal-dependent dimming cannot be measured; Unknown prevents a confirmed pass but is not a failure. The output report has Passed and Results properties and a verdict-first default view showing problems and unknowns. Use -Detailed for every check. Dark and Light are not colour-blind-safe presets.
Examples
Example 1
Test-ConsoleThemeCheck the active theme.
Example 2
Test-ConsoleTheme -Path ./team-theme.json -StrictCheck a team theme in CI; any failure stops the script.
Example 3
(Test-ConsoleTheme -Theme Light -Background '#ffffff').Results | Where-Object Outcome -EQ FailInspect individual measurements as objects.
Example 4
Test-ConsoleTheme -Theme Dark -DetailedShow every measurement.
Parameters
- -Background String
- The page colour, as a name or #rrggbb. Defaults to #0c0c0c for a dark preset and #ffffff for a light preset. A token's own background takes precedence. Palette-index backgrounds remain unknown.
- -Detailed SwitchParameter
- Shows every measurement instead of only problems and unknowns. The Results property always contains every check.
- -Strict SwitchParameter
- Makes any Fail a terminating ConsoleThemeCheckFailed error with the report as its target. Unknown alone does not throw.
- -Theme String
- A built-in preset, catalogue scheme or family. Catalogue names accept · accessible. Omit both Theme and Path to check the active theme. Paired families and ColorBlindSafe select the detected background; explicit variant names choose one.
- -Path String
- A literal .json or restricted .psd1 theme file. Relative paths use the current PowerShell location.
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.