Convert Upper case to Lower Case on CSV content through PowerShell

Occasional Contributor

Hello,

 

I  tried following PowerShell script and it work well but some how it convert whole string from Upper to lower. i need to keep first letter of string as upper , do not want to cover as lower for first letter.

 

$a = "E:\User\Staff\cims"
$b = (get-content "$a\staff.csv" -raw)
(("$b").ToLower()).trim(" ") -split (",,") |
Out-File -FilePath E:\User\Staff\cims\staff1.csv -Encoding UTF8 |
Get-Process | Out-Host -Paging| Format-Table -wrap -Property Emp,LastFirst,Last,First,email.title,location

 

Thank you

4 Replies

Something like this should do it:

 

($b[0] + $b.Substring(1).ToLower()).Trim(" ") -split ...

@Vasil Michev 

 

Thank you!

It is still returning all lower case instead of first letter capital and reset are lower case.

@Vasil Michev 

 

Fixed through following script,

 

$TextInfo = (Get-Culture).textinfo
$TextInfo.ToTitleCase($b[0] + $b.Substring(1).ToLower()).Trim(" ") -split(",,") |

Well it's more fun if you get just the building blocks and do the complete solution yourself :p Or in other words I was being lazy and didn't want to copy/paste the entire script sample.