Skip to content

Convert PesterSyntax

viscalyxbot edited this page Aug 2, 2024 · 3 revisions

Convert-PesterSyntax

SYNOPSIS

Converts the syntax of a file to the syntax of a newer Pester version.

SYNTAX

Convert-PesterSyntax -Path <String[]> [-Pester6] [-UseNamedParameters] [-UsePositionalParameters] [-Force]
 [-PassThru] [-OutputPath <String>] [-WhatIf] [-Confirm]
 [<CommonParameters>]

DESCRIPTION

The Convert-PesterSyntax command is used to convert the syntax of a file to the syntax of a newer Pester version.. It supports converting to Pester 6 format.

EXAMPLES

EXAMPLE 1

Convert-PesterSyntax -Path "C:\Scripts\Test.ps1" -Pester6

Converts the syntax of the Test.ps1 file to Pester 6 syntax.

EXAMPLE 2

Get-ChildItem -Path "C:\Scripts" -Recurse -Filter "*.ps1" | Convert-PesterSyntax -Pester6

Converts the syntax of all PowerShell files in the C:\Scripts directory and its subdirectories to Pester 6 syntax.

EXAMPLE 3

Convert-PesterSyntax -Path (Get-ChildItem -Path "C:\Scripts" -Recurse -Filter "*.ps1") -Pester6

Converts the syntax of all PowerShell files in the C:\Scripts directory and its subdirectories to Pester 6 syntax.

PARAMETERS

-Force

Specifies that the file should be created without any confirmation.

Type: SwitchParameter
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False

-OutputPath

Specifies the path to save the converted file(s). If this parameter is not specified, the original file(s) will be overwritten.

Type: String
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-PassThru

Returns the script after converting the syntax. This parameter is most useful when passing in a single file to convert. If multiple files are passed in, the script of all the files will be returned as an array. If PassThru is specified, no file will not be modified.

Type: SwitchParameter
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False

-Path

Specifies the path of the file(s) to be converted. This parameter is mandatory and accepts a string or a FileInfo object.

Type: String[]
Parameter Sets: (All)
Aliases:

Required: True
Position: Named
Default value: None
Accept pipeline input: True (ByPropertyName, ByValue)
Accept wildcard characters: False

-Pester6

Specifies that the syntax to convert to is Pester 6. This parameter is mandatory to convert to Pester 6 syntax.

Type: SwitchParameter
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False

-UseNamedParameters

Specifies whether to use named parameters in the converted syntax.

Type: SwitchParameter
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False

-UsePositionalParameters

Specifies whether to use positional parameters in the converted syntax, where supported.

Type: SwitchParameter
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False

-Confirm

Prompts you for confirmation before running the cmdlet.

Type: SwitchParameter
Parameter Sets: (All)
Aliases: cf

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-WhatIf

Shows what would happen if the cmdlet runs. The cmdlet is not run.

Type: SwitchParameter
Parameter Sets: (All)
Aliases: wi

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.

INPUTS

OUTPUTS

NOTES

RELATED LINKS

Clone this wiki locally