سؤال

#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