-
-
Save sysmadmin/129b8500ff46dc8b9a29 to your computer and use it in GitHub Desktop.
Capitalizing First Letters Only
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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