mirror of
https://github.com/EvotecIT/GPOZaurr.git
synced 2026-07-26 11:49:17 +00:00
27 lines
930 B
PowerShell
27 lines
930 B
PowerShell
function Format-CamelCaseToDisplayName {
|
|
[cmdletBinding()]
|
|
param(
|
|
[string[]] $Text,
|
|
[string] $AddChar
|
|
)
|
|
foreach ($string in $Text) {
|
|
$newString = ''
|
|
$stringChars = $string.GetEnumerator()
|
|
$charIndex = 0
|
|
foreach ($char in $stringChars) {
|
|
# If upper and not first character, add a space
|
|
if ([char]::IsUpper($char) -eq 'True' -and $charIndex -gt 0) {
|
|
$newString = $newString + $AddChar + $char.ToString()
|
|
} elseif ($charIndex -eq 0) {
|
|
# If the first character, make it a capital always
|
|
$newString = $newString + $char.ToString().ToUpper()
|
|
} else {
|
|
$newString = $newString + $char.ToString()
|
|
}
|
|
$charIndex++
|
|
}
|
|
$newString
|
|
}
|
|
}
|
|
|
|
#Format-CamelCaseToDisplayName -Text 'Test1', 'TestingMyAss', 'OtherTest', 'otherTEst' |