# Convert-ProjectConsistency

Converts a project to a consistent encoding/line ending policy and reports the results.

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`

Converts a project to a consistent encoding/line ending policy and reports the results.

## Syntax

```
Convert-ProjectConsistency
[-BackupDirectory <String>]
[-CreateBackups]
[-CustomExtensions <String[]>]
[-EncodingOverrides <IDictionary>]
[-EnsureFinalNewline]
[-ExcludeDirectories <String[]>]
[-ExcludeFiles <String[]>]
[-ExportPath <String>]
[-FixEncoding]
[-FixLineEndings]
[-Force]
[-LineEndingOverrides <IDictionary>]
[-NoRollbackOnMismatch]
[-OnlyMissingFinalNewline]
[-OnlyMixedLineEndings]
-Path <String>
[-ProjectType <PowerShell|CSharp|Mixed|All|Custom>]
[-RequiredEncoding <FileConsistencyEncoding>]
[-RequiredLineEnding <CRLF|LF>]
[-ShowDetails]
[-SourceEncoding <TextEncodingKind>]
[<CommonParameters>]
```

[#](#member-ad81424cd601af86dd4776b1)

Parameter set: `All Parameter Sets`

## Description

This cmdlet applies a consistency policy (encoding and/or line endings) across a project tree. It can also export a post-conversion report so you can validate what remains inconsistent.

For build-time enforcement, use New-ConfigurationFileConsistency -AutoFix in the module build pipeline.

## Examples

### Convert a PowerShell project to UTF-8 BOM + CRLF

```powershell
Convert-ProjectConsistency -Path 'C:\MyProject' -ProjectType PowerShell -CreateBackups
```

Ensures PowerShell-friendly encoding and line endings, creating backups before changes.

### Convert line endings only for a cross-platform repo

```powershell
Convert-ProjectConsistency -Path 'C:\MyProject' -FixLineEndings -RequiredLineEnding LF -ExcludeDirectories 'Build','Docs'
```

Normalizes line endings to LF and skips non-source folders.

### Convert encoding only with per-extension overrides

```powershell
Convert-ProjectConsistency -Path 'C:\MyProject' -FixEncoding -RequiredEncoding UTF8BOM -EncodingOverrides @{ '*.xml' = 'UTF8' } -ExportPath 'C:\Reports\consistency.csv'
```

Uses UTF-8 BOM by default but keeps XML files UTF-8 without BOM, and writes a report.

## Parameters

**-BackupDirectory String optional**

Backup root folder (mirrors the project structure).

**-CreateBackups SwitchParameter optional**

Create backup files before modifying content.

**-CustomExtensions String[] optional**

Custom file extensions to include when ProjectType is Custom (e.g., *.ps1, *.cs).

**-EncodingOverrides IDictionary optional**

Per-path encoding overrides (hashtable of pattern => encoding).

**-EnsureFinalNewline SwitchParameter optional**

Ensure a final newline exists after line ending conversion.

**-ExcludeDirectories String[] optional**

Directory names to exclude from conversion (e.g., .git, bin, obj).

**-ExcludeFiles String[] optional**

File patterns to exclude from conversion.

**-ExportPath String optional**

Export the detailed report to a CSV file at the specified path.

**-FixEncoding SwitchParameter optional**

Convert encoding inconsistencies.

**-FixLineEndings SwitchParameter optional**

Convert line ending inconsistencies.

**-Force SwitchParameter optional**

Force conversion even when the file already matches the target.

**-LineEndingOverrides IDictionary optional**

Per-path line ending overrides (hashtable of pattern => line ending).

**-NoRollbackOnMismatch SwitchParameter optional**

Do not rollback from backup if verification mismatch occurs during encoding conversion.

**-OnlyMissingFinalNewline SwitchParameter optional**

Only fix files missing the final newline.

**-OnlyMixedLineEndings SwitchParameter optional**

Only convert files that have mixed line endings.

**-Path String required**

Path to the project directory to convert.

**-ProjectType String optional**

Type of project to analyze. Determines which file extensions are included.

Possible values: `PowerShell`, `CSharp`, `Mixed`, `All`, `Custom`

**-RequiredEncoding FileConsistencyEncoding optional**

Target encoding to enforce when fixing encoding consistency.

Possible values: `ASCII`, `UTF8`, `UTF8BOM`, `Unicode`, `BigEndianUnicode`, `UTF7`, `UTF32`

**-RequiredLineEnding FileConsistencyLineEnding optional**

Target line ending style to enforce when fixing line endings.

Possible values: `CRLF`, `LF`

**-ShowDetails SwitchParameter optional**

Include detailed file-by-file analysis in the output.

**-SourceEncoding TextEncodingKind optional**

Source encoding filter. When Any, any non-target encoding may be converted.

Possible values: `Ascii`, `BigEndianUnicode`, `Unicode`, `UTF7`, `UTF8`, `UTF8BOM`, `UTF32`, `Default`, `OEM`, `Any`

## 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:41B39514763C008123517E1D6114A11ADF516F7686DD6C9BA738C54FEA773D84 -->
