Hey!
I'm new to Powershell and trying to read out the user name, givenname, surname and group membership of a AD user and put this as one row in a CSV file.
I found a command in the forum that works fine, but I don't know how to modify it, that it puts out the groups in one row.
get-aduser testuser -properties memberof,samaccountname,givenname,surname | select samaccountname,givenname,surname, @{name="Groups";expression={$_.memberof}} | export-csv "D:\ADUsers.csv" -Delimiter ";" -NoTypeInformation -Encoding UTF8
The command does what I want, but it adds things like "CN=\itusers,CN=Users,DC=dcmydom,DC=local" to the groupname.
I want the output to be the same as the output of this command (just the groupnames, but in one line ):
Get-ADPrincipalGroupMembership testuser | select name | Export-Csv .\export2.csv -Delimiter ";" -NoTypeInformation -Encoding UTF8
Example: #itusers, finances, HR, examplegroup, examplegroup2
Thanks for your help!