Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Function to format words as UpppercaseLowerCase
Function Format-WordCase {
Formats a string as uppercase first letter of each word
The function will take any string and parses each word in order to apply an uppercase first letter and then lowercase every other letter of the word.
Format-WordCase -String "MY STRING has NO SPEcfic case HeRe"
This cmdlet will output "My String Has No Specfic Case Here".
"MY STRING has NO SPEcfic case HeRe", "we are the champions" | Format-WordCase
Formatting words by piping directly an array.
Quick function for Mike F. Robbins contest
Param (
$String -split " " | ForEach-Object{
$Case = $_.SubString(0,1).ToUpper()
$Case += $_.Substring(1).ToLower() + " "
Write-Verbose -Message "Modified `"$_`" to `"$Case`""
} | ForEach-Object{
$Final += $Case
Write-Verbose -Message "$Final - $Case"
Remove-Variable Case,Final
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment