Thor Logo dbatools

Invoke-DbatoolsFormatter

View Source
Simone Bizzotto
Windows, Linux, macOS

Synopsis

Formats PowerShell function files to dbatools coding standards

Description

Applies consistent code formatting to PowerShell files using PSScriptAnalyzer’s Invoke-Formatter with OTBS (One True Brace Style) settings. This function standardizes indentation, brace placement, and whitespace handling across all dbatools module files, ensuring code consistency for contributors and maintainers. Files are saved without BOM encoding and with proper line ending handling for cross-platform compatibility.

Syntax

Invoke-DbatoolsFormatter
    [-Path] <Object[]>
    [-EnableException]
    [<CommonParameters>]

 

Examples

 

Example: 1
PS C:\> Invoke-DbatoolsFormatter -Path C:\dbatools\public\Get-DbaDatabase.ps1

Reformats C:\dbatools\public\Get-DbaDatabase.ps1 to dbatools’ standards

Required Parameters

-Path

Specifies the path to one or more PowerShell (.ps1) files that need to be formatted to dbatools coding standards.
Accepts pipeline input from Get-ChildItem or other file listing commands for batch processing multiple files.
Use this when you want to apply consistent OTBS formatting, proper indentation, and standardized brace placement to your dbatools contributions.

PropertyValue
AliasFullName)
RequiredTrue
Pipelinetrue (ByValue)
Default Value

Optional Parameters

-EnableException

By default, when something goes wrong we try to catch it, interpret it and give you a friendly warning message.
This avoids overwhelming you with “sea of red” exceptions, but is inconvenient because it basically disables advanced scripting.
Using this switch turns this “nice by default” feature off and enables you to catch exceptions with your own try/catch.

PropertyValue
Alias
RequiredFalse
Pipelinefalse
Default ValueFalse