Skip to content

Instantly share code, notes, and snippets.

@sysmadmin

sysmadmin/Set-Capitalization Secret

Last active Sep 25, 2015
Embed
What would you like to do?
Capitalizing First Letters Only
Function Set-Capitalization {
<#
.SYNOPSIS
Displays submitted text with only the first letter of each word capitalized
.DESCRIPTION
Set-Capitalization takes the text given to its Text parameter (either through the pipeline or directly) and capitalizes the first letter of each word while making the rest of the word lower case.
.PARAMETER Text
Accepts a string
.EXAMPLE
"HelLo, thIs IS a Bad SentenCE." | Set-Capitalization
This will take the sentence above and output: "Hello, This Is A Bad Sentence"
.EXAMPLE
Set-Capitalization "ANOTHER bad SENTENCE for TESTING"
This will output "Another Bad Sentence For Testing"
#>
param(
[Parameter(ValueFromPipeline=$True,Mandatory=$True,Position=0)]
$Text
)
$Text = $Text.ToLower()
(Get-Culture).TextInfo.ToTitleCase($Text)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment