I can only get the length when exporting this to csv, how should it be done properly.
$redo = Import-CSV c:\\temp\\testimport.txt | Group-Object email |
fore
This was exactly what I was looking for. So I'm just going to add, my comment to be sure everyone understands.
This does NOT work:
$str_list = @('Mark','Henry','John')
$str_list | Export-Csv .\ExportStrList.csv -NoType
Because Export-Csv takes Objects and outputs properties. The only properties for a String[ ] is Length, so the CSV file only contains Lengths.
To fix this, like the last guy said, we need to change the String[ ] into an Object[ ]. The simplest way is with Select-Object.
Put each String into the Name property of a new Object[ ], like this:
$str_list = @('Mark','Henry','John')
$str_list = $str_list | Select-Object @{Name='Name';Expression={$_}}
$str_list | Export-Csv .\ExportStrList.csv -NoType
Just to re-iterate, Select-Object outputs a custom PSObject that can easily be manipulated. This is very powerful information, use it wisely.