A
A
Anton Pavlov2018-11-03 10:20:04
Active Directory
Anton Pavlov, 2018-11-03 10:20:04

How to export users from AD with the groups they belong to?

The idea is this. Unload users with the groups they belong to. Then throw in the table
OU | USER | GROUP
I just can't figure out how to do it.
dsquery user ou=users,ou=IRNU,ou=AO,dc=oms,dc=tn,dc=corp -limit 500 -name *> c:\users.txt
Displays users from the OU in which they are sitting.
dsquery group ou=groups,ou=XXX,ou=XXX,dc=XXX,dc=XXX,dc=corp -limit 500 | dsget group -members | dsget user -samid -c >> c:\groupmembers.txt
Error "The target class of the object does not match the one specified on the command line."

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
akelsey, 2018-11-05
@akelsey

Something like this:

import-module activedirectory
Get-ADGroup -Filter * | % {foreach ($z in Get-ADGroupMember -Identity $_) {Write-Host $($_.Name),$($z.Samaccountname)"}}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question