Get-ADUser -LDAPFilter "(name=*)" -SearchScope Subtree `
-SearchBase "OU=path,OU=path,DC=path,DC=path,DC=path" | %{
$user = $_
$user | Get-ADPrincipalGroupMembership |
Select @{N="User";E={$user.sAMAccountName}},@{N="Group";E={$_.Name}}
}| Select User,Group | Export-Csv C:\Temp\Report.csv -nti
Change the wildcard in "(name=*)" to for example QUSR to find all groups and users starting with these letters.
ReplyDelete