# Get-PowerShellCompatibility

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

Project

PSPublishModule

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

[View on GitHub](https://github.com/EvotecIT/PSPublishModule) [Visit Website](#) [Releases](https://github.com/EvotecIT/PSPublishModule/releases/tag/v3.0.124) [Changelog](#) [Get package](https://www.powershellgallery.com/packages/PSPublishModule/2.0.27)

Stars **48**

Forks **15**

Open issues **1**

PowerShell Gallery downloads **17,213**

Release **v3.0.195**

Language: C# Updated: 2026-11-25

Command 

**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>]
```

[#](#method-get-powershellcompatibility-string-string-string-switchparameter-switchparameter)

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

### Analyze a module folder

```powershell
Get-PowerShellCompatibility -Path 'C:\MyModule'
```

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

### Recursively analyze and include detailed findings

```powershell
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

```powershell
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](https://learn.microsoft.com/powershell/module/microsoft.powershell.core/about/about_commonparameters).

Evotec API Reference Copyright 2026 Evotec Services

<!-- PowerForge markdown artifact sha256:C4334CD90D12D22505CD3AE1EEE59B5FEF3866FF21FD6C0397AF9E53056E5204 -->
