Convert String Case
Last Modified: February 25, 2024 18:18 CEST

Convert-StringCase #

SYNOPSIS #

This PowerShell function converts text to lowercase, uppercase, or capitalized. Source code on GitHub.

SYNTAX #

Convert-StringCase [[-value] <String>] [[-strCase] <String>] [-ProgressAction <ActionPreference>]
 [<CommonParameters>]

DESCRIPTION #

Converts text to lowercase, uppercase, or capitalized. With Capitalized, only the first letter starts in upper case.

EXAMPLES #

Example 1:Converts text in upper case #

PS C:\> [string]$myOutput= Convert-StringCase -value 'Hello, i am John, John Doe' -strCase upper
PS C:\> Write-Host $myOutput
# Output

HELLO, I AM JOHN, JOHN DOE

The text specified in value is converted to uppercase. The strCase parameter also allows conversion to lowercase or capitalized.

PARAMETERS #

-strCase #

By setting the parameter strCase you can influence the output. If the parameter is omitted or set to none, no further conversion is performed. With lower the output is converted to lowercase, with upper to uppercase and with capitalize the first letter of a word is output in uppercase.

Type: String
Parameter Sets: (All)
Aliases:

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

-value #

The text to be converted

Type: String
Parameter Sets: (All)
Aliases:

Required: False
Position: 0
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 #

None #

OUTPUTS #

System.Object #

NOTES #