Export-Csv
expects an object (or a list of objects) with properties, whereas your command pipeline produces an array of strings. If you feed this array into Export-Csv
the cmdlet takes the properties of each given item (which is only Length
for strings) and writes those properties to the output file.
You need to build a list of objects with the desired properties instead, e.g.:
Import-CSV c:empestimport.txt `
| Group-Object email `
| select @{n="Name";e={$_.Name}},@{n="Group";e={($_.Group | %{$_.group}) -join ', '}} `
| Export-CSV c:empest.csv -NoTypeInformation
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…