Author Posts

May 30, 2017 at 2:21 am

$names = 'john smith', 'ludwig van beethoven', 'george washington', 'james van der kampf'

foreach ($name in $names) {
$firstName = (Get-Culture).TextInfo.ToTitleCase($name.split()[0])

$lastName = "
for ($i = 1; $i -lt $name.split().count; $i++) {
if ($i -eq $name.split().count – 1) {
$lastName += (Get-Culture).TextInfo.ToTitleCase($name.split()[$i])
} else {
$lastName += $name.split()[$i] + ' '
}
}

Write-Output "$firstName $lastName"
}

May 30, 2017 at 3:23 am

add a line
for($name in $names){
$name=name.toupper()

May 30, 2017 at 11:40 am

Hi, give this a shot

$names = 'john smith', 'ludwig van beethoven', 'george washington', 'james van der kampf'
$names.ForEach({
    [string]$fistname, [string]$lastname = $PSItem.split()
    Write-Output "$($fistname.ToUpper()) $((Get-Culture).TextInfo.ToTitleCase($lastname))"
})