Pergunta

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

Foi útil?

Solução

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.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top