Project

PSPublishModule

Build, test, version, sign, and publish PowerShell modules with reusable PowerForge pipelines.

Stars 48
Forks 16
PowerShell Gallery downloads 17,213
Release v3.0.169
Language: C# Updated: 2026-10-17
Command

Get-PowerShellCompatibility

Module PSPublishModule
Inputs
None

Analyzes PowerShell files and folders to determine compatibility with Windows PowerShell 5.1 and PowerShell 7+.

Syntax

Get-PowerShellCompatibility [-ExcludeDirectories <String[]>] [-ExportPath <String>] -Path <String> [-Recurse] [-ShowDetails] [<CommonParameters>]
#
Parameter set: All Parameter Sets

Description

Scans PowerShell files to detect patterns and constructs that can cause cross-version issues (Windows PowerShell 5.1 vs PowerShell 7+), and outputs a compatibility report.

Use this as part of CI to keep modules compatible across editions, and pair it with encoding/line-ending checks when supporting Windows PowerShell 5.1.

Examples

Authored help example

Analyze a module folder

Get-PowerShellCompatibility -Path 'C:\MyModule'

Analyzes PowerShell files in the folder and returns a compatibility report.

Recursively analyze and include detailed findings

Get-PowerShellCompatibility -Path 'C:\MyModule' -Recurse -ShowDetails

Useful when investigating why a module behaves differently in PS 5.1 vs PS 7+.

Export compatibility findings to CSV

Get-PowerShellCompatibility -Path 'C:\MyModule' -ExportPath 'C:\Reports\compatibility.csv'

Creates a report that can be attached to CI artifacts.

Parameters

-ExcludeDirectories String[] optional
Directory names to exclude from analysis.
-ExportPath String optional
Export the detailed report to a CSV file at the specified path.
-Path String required
Path to the file or directory to analyze for PowerShell compatibility.
-Recurse SwitchParameter optional
When analyzing a directory, recursively analyze all subdirectories.
-ShowDetails SwitchParameter optional
Include detailed analysis of each file with specific compatibility issues found.

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.