API Reference
New-ConfigurationFormat
Builds formatting options for code and manifest generation during the build.
Remarks
Produces a formatting configuration segment used by the build pipeline to normalize generated output (merged PSM1/PSD1) and optionally apply formatting back to the project root.
Examples
Remove comments and normalize whitespace during merge
PS>
New-ConfigurationFormat -ApplyTo OnMergePSM1,OnMergePSD1 -RemoveComments -RemoveEmptyLines
Formats the merged module output and removes comments while keeping readability.
Also update files in the project root
PS>
New-ConfigurationFormat -ApplyTo DefaultPSM1,DefaultPSD1 -EnableFormatting -UpdateProjectRoot
Applies formatting rules to the project sources as well as generated output.
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.
Syntax
New-ConfigurationFormat [-AlignAssignmentStatementCheckHashtable] [-AlignAssignmentStatementEnable] -ApplyTo <OnMergePSM1|OnMergePSD1|DefaultPS1|DefaultPSM1|DefaultPSD1> [-EnableFormatting] [-PlaceCloseBraceEnable] [-PlaceCloseBraceIgnoreOneLineBlock] [-PlaceCloseBraceNewLineAfter] [-PlaceCloseBraceNoEmptyLineBefore] [-PlaceOpenBraceEnable] [-PlaceOpenBraceIgnoreOneLineBlock] [-PlaceOpenBraceNewLineAfter] [-PlaceOpenBraceOnSameLine] [-PSD1Style <Minimal|Native>] [-RemoveAllEmptyLines] [-RemoveComments] [-RemoveCommentsBeforeParamBlock] [-RemoveCommentsInParamBlock] [-RemoveEmptyLines] [-Sort <Asc|Desc>] [-UpdateProjectRoot] [-UseConsistentIndentationEnable] [-UseConsistentIndentationIndentationSize <Int32>] [-UseConsistentIndentationKind <space|tab>] [-UseConsistentIndentationPipelineIndentation <IncreaseIndentationAfterEveryPipeline|NoIndentation>] [-UseConsistentWhitespaceCheckInnerBrace] [-UseConsistentWhitespaceCheckOpenBrace] [-UseConsistentWhitespaceCheckOpenParen] [-UseConsistentWhitespaceCheckOperator] [-UseConsistentWhitespaceCheckPipe] [-UseConsistentWhitespaceCheckSeparator] [-UseConsistentWhitespaceEnable] [-UseCorrectCasingEnable] [<CommonParameters>]
#
All Parameter SetsParameters
- AlignAssignmentStatementCheckHashtable SwitchParameter
- For PSAlignAssignmentStatement: align hashtable assignments.
- AlignAssignmentStatementEnable SwitchParameter
- Enable PSAlignAssignmentStatement rule and optionally check hashtable alignment.
- ApplyTo String[]
- Targets to apply formatting to (OnMergePSM1, OnMergePSD1, DefaultPS1, DefaultPSM1, DefaultPSD1).
- Possible values:
OnMergePSM1,OnMergePSD1,DefaultPS1,DefaultPSM1,DefaultPSD1 - EnableFormatting SwitchParameter
- Enables formatting for the chosen ApplyTo targets even if no specific rule switches are provided.
- PlaceCloseBraceEnable SwitchParameter
- Enable PSPlaceCloseBrace rule and configure its behavior.
- PlaceCloseBraceIgnoreOneLineBlock SwitchParameter
- For PSPlaceCloseBrace: ignore single-line blocks.
- PlaceCloseBraceNewLineAfter SwitchParameter
- For PSPlaceCloseBrace: enforce a new line after the closing brace.
- PlaceCloseBraceNoEmptyLineBefore SwitchParameter
- For PSPlaceCloseBrace: do not allow an empty line before a closing brace.
- PlaceOpenBraceEnable SwitchParameter
- Enable PSPlaceOpenBrace rule and configure its behavior.
- PlaceOpenBraceIgnoreOneLineBlock SwitchParameter
- For PSPlaceOpenBrace: ignore single-line blocks.
- PlaceOpenBraceNewLineAfter SwitchParameter
- For PSPlaceOpenBrace: enforce a new line after the opening brace.
- PlaceOpenBraceOnSameLine SwitchParameter
- For PSPlaceOpenBrace: place opening brace on the same line.
- PSD1Style String
- Style for generated manifests (PSD1) for the selected ApplyTo targets.
- Possible values:
Minimal,Native - RemoveAllEmptyLines SwitchParameter
- Remove all empty lines (more aggressive than RemoveEmptyLines).
- RemoveComments SwitchParameter
- Remove comments in the formatted output.
- RemoveCommentsBeforeParamBlock SwitchParameter
- Remove comments that appear immediately before the param() block.
- RemoveCommentsInParamBlock SwitchParameter
- Remove comments within the param() block.
- RemoveEmptyLines SwitchParameter
- Remove empty lines while preserving readability.
- Sort String
- Optional ordering hint for internal processing. Accepts None, Asc, or Desc.
- Possible values:
Asc,Desc - UpdateProjectRoot SwitchParameter
- When set, formats PowerShell sources in the project root in addition to staging output.
- UseConsistentIndentationEnable SwitchParameter
- Enable PSUseConsistentIndentation rule and configure its behavior.
- UseConsistentIndentationIndentationSize Int32
- Number of spaces for indentation when Kind is space.
- UseConsistentIndentationKind String
- Indentation style for PSUseConsistentIndentation: space or tab.
- Possible values:
space,tab - UseConsistentIndentationPipelineIndentation String
- Pipeline indentation mode for PSUseConsistentIndentation.
- Possible values:
IncreaseIndentationAfterEveryPipeline,NoIndentation - UseConsistentWhitespaceCheckInnerBrace SwitchParameter
- For PSUseConsistentWhitespace: check inner brace spacing.
- UseConsistentWhitespaceCheckOpenBrace SwitchParameter
- For PSUseConsistentWhitespace: check open brace spacing.
- UseConsistentWhitespaceCheckOpenParen SwitchParameter
- For PSUseConsistentWhitespace: check open parenthesis spacing.
- UseConsistentWhitespaceCheckOperator SwitchParameter
- For PSUseConsistentWhitespace: check operator spacing.
- UseConsistentWhitespaceCheckPipe SwitchParameter
- For PSUseConsistentWhitespace: check pipeline operator spacing.
- UseConsistentWhitespaceCheckSeparator SwitchParameter
- For PSUseConsistentWhitespace: check separator (comma) spacing.
- UseConsistentWhitespaceEnable SwitchParameter
- Enable PSUseConsistentWhitespace rule and configure which elements to check.
- UseCorrectCasingEnable SwitchParameter
- Enable PSUseCorrectCasing rule.
Outputs
System.Object