Hello Scripting Guru,
I just can't seems to find a way to have powershell to list all users in an OU and the group membership of all each users.
This is my PS command:
Get-ADUser -Filter * -SearchBase 'OU=Admin,OU=Users,DC=contoso,DC=com' -Properties MemberOf |Select-Object SamAccountName, @{n='memberOf';e={$_.memberOf -replace '^CN=([^,]+).+$','$1' }}
And this is the output:
jsmith contoso-Employees O365 A5 Employees Remote FINANCE Accounting All Employees DL-Financial Secretaries DL-Administration - OSP HERT-GLOBAL DL-AdvantageGroup OSP-OFFICE Audit.
How do I change the PS command so it will list user account with membership like below:
SamAccountName Member of
Jsmith contoso-Employees
O365 A5 Employees
FINANCE Accounting
All Employees
Jdoe All Employees
Security Admin
Citrix Admin
Citrix VDI
Thanks for your help