Question

#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.

Était-ce utile?

La solution

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.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top