I am quite new to PowerShell and on the site.
My issue is that I found a script which I have modified. The script is working, but only partial; it is not returning all the groups. Only 4 groups and after that is displaying "....." and no other info (you can see the picture).
Basically what I want to do is the following:
I have 100 users and I need to export the group membership of these 100 users.
[$users = Get-Content "D:\users.txt"
$adjob = foreach ($user in $users) {
Get-ADUser -server "myserver" –Identity $user –Properties MemberOf
}
$adjob | Select-Object Name,@{N='Group';E={$_.MemberOf -replace '^CN=(\[^,\]+),OU=.+$','$1'}} | Format-Table -AutoSize | out-file D:\users.csv][1]
Thise script should return:
name
user1
user2
user3
group
group1,group2,group3,rest of the groups for each User
group1,group2,group3,rest of the groups for each User
group1,group2,group3,rest of the groups for each User
Thank you for the help!