문제

#First Name
$GivenName = Import-Csv .\Documents\db1.csv | select GivenName 

$UserF = (Get-Culture).TextInfo.ToTitleCase($GivenName) 

$UserF | Export-Csv .\Documents\UsersF.txt –NoTypeInformation

When I run the script I get a .txt file with

#TYPE System.String
"Length"
"98"

What I want is the FirstName category with the proper Title Case.

도움이 되었습니까?

해결책

I think it may be simpler than expected. Just update you existing $GivenName like this:

$GivenName|%{$_.givenname = (Get-Culture).TextInfo.ToTitleCase($_.GivenName)}

Then you can do a $GivenName|Export-CSV .\Documents\UsersF.txt -NoTypeInformation and there's no need to create a whole other variable for the exact same info.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top