Skip to content

Instantly share code, notes, and snippets.

@gravejester
Last active August 29, 2015 14:11
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
function Out-CapitalizedString {
param([string]$String)
if(-not([System.String]::IsNullOrEmpty($String))) {
foreach ($sentence in ($String.Split('.'))) {
if(-not([System.String]::IsNullOrEmpty($sentence))) {
$sentence = $sentence.Trim()
[array]$outputString += [char]::ToUpper($sentence[0]) + $sentence.Substring(1)
}
else {
[array]$outputString += $sentence
}
}
Write-Output ($outputString -join '. ').Trim()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment