Isso ajuda?
$CSV = Import-Csv C:\Users\Ryan\Downloads\test.txt
$ReformattedUsers = @()
Foreach ($User In $CSV)
{
Foreach ($Group In $User.Groups.Split('|'))
{
$ReformattedUsers += [PSCustomObject]@{ 'UserID' = $User.UserID; '
'Groups' = $Group; '
'Join Date' = $User.'Join Date'; '
'Referal (sic)' = $User.Referal }
}
}
$ReformattedUsers | Format-Table -AutoSize
$ReformattedUsers | Export-Csv C:\Users\Ryan\Downloads\out.csv -NoTypeInformation
Saída:
UserID Groups Join Date Referal (sic)
------ ------ --------- -------------
123 Group A
123 Group B
123 Group C
O CSV resultante é semelhante a:
"UserID","Groups","Join Date","Referal (sic)"
"123","Group A","",""
"123","Group B","",""
"123","Group C","",""