Skip to content
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) →

Sponsor

Get-MtTestInventory

Discover Pester test inventory and associated tags.

Get-MtTestInventory [-Path <String>] [-ExcludePath <String[]>] [-ExcludeTag <String[]>] [-OutputType <String>]
[-ExportPath <String>] [-PassThru] [-ProgressAction <ActionPreference>] [<CommonParameters>]

Uses Pester discovery to enumerate all tests under the provided path and returns a list of objects containing:

TestName - Name of the It test. FilePath - Full path to the test file. Describe - Name of the parent Describe block. Tags - Tags explicitly set on the test. CombinedTags - Combination of Describe and Tags (unique, case-insensitive).

$TestInventory = Get-MtTestInventory -Path .\ -ExcludePath .\test-results

Get an inventory of tests in the current directory and exclude anything in the ‘test-results’ sub-directory.

$TagInventory = Get-MtTestInventory
$TagInventory['CIS']

Get test test inventory and show tests with the ‘CIS’ tag.

$Tags = Get-MtTestInventory
$Tags -notmatch 'AzureConfig|CIS|CISA|Maester|MT.\d{4,5}|ORCA'

Show all tags used that do not match the specified tag patterns.

$TagInventory = Get-MtTestInventory
$TagInventory.Keys -notmatch 'AzureConfig|CIS|CISA|Maester|MT.\d{4,5}|ORCA'

foreach ($i in $TagInventory.GetEnumerator()) { if ($i.Key -notmatch ‘AzureConfig|CIS|CISA|Maester|MT.\d{4,5}|ORCA’) { $i } }

Show all tags used that do not match the specified tag patterns, along with their test objects.

Root path containing the test files. Defaults to the ’..\tests’ directory in the current location.

Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: (Resolve-Path -LiteralPath (Join-Path -Path $PSScriptRoot '..\..' 'tests')).Path
Accept pipeline input: False
Accept wildcard characters: False

One or more paths to exclude (e.g. ‘test-results’ directory). Accepts wildcard patterns and relative paths.

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

One or more tags to exclude from discovery.

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

Specify a desired output type for the test inventory:

  • Default: Returns the test inventory as objects.
  • JSON: Returns the test inventory as a JSON string.
  • CSV: Returns the test inventory as a CSV string.
  • TagsOnly: Returns only the unique tags found in the test inventory.
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: Default
Accept pipeline input: False
Accept wildcard characters: False

Path for exported CSV or JSON file. Defaults to ‘TestInventory’ in the current directory.

Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: (Join-Path -Path $PWD -ChildPath 'TestInventory')
Accept pipeline input: False
Accept wildcard characters: False

When specified, the test inventory object is returned to the pipeline along with exporting to file.

Type: SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: False
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.

[Ordered] (Default) - An ordered dictionary containing a list of tags and associated test inventory objects.

Section titled “[Ordered] (Default) - An ordered dictionary containing a list of tags and associated test inventory objects.”

[String] - JSON string of test inventory (when OutputType is ‘JSON’).

Section titled “[String] - JSON string of test inventory (when OutputType is ‘JSON’).”

[String] - CSV string of test inventory (when OutputType is ‘CSV’).

Section titled “[String] - CSV string of test inventory (when OutputType is ‘CSV’).”

[String[]] - Array of unique tags (when OutputType is ‘TagsOnly’).

Section titled “[String[]] - Array of unique tags (when OutputType is ‘TagsOnly’).”

Requires Pester 5+.

https://maester.dev/docs/commands/Get-MtTestInventory