Skip to content

Instantly share code, notes, and snippets.

@sysmadmin
Last active September 25, 2015 19:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sysmadmin/129b8500ff46dc8b9a29 to your computer and use it in GitHub Desktop.
Save sysmadmin/129b8500ff46dc8b9a29 to your computer and use it in GitHub Desktop.
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