Need to export users from AD group

I have a group that contains some users and group and query groups. I need to export the list of all of them and include the sub groups with the users and what sub groups they are a part of?  Does that make sense? :)

Thanks
rdefinoAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

FOXActive Directory/Exchange EngineerCommented:
Get-ADNestedGroupMembers -GroupName "thegroupname" | out-file -Filepath pathtoyourfile.txt
0
rdefinoAuthor Commented:
Get-ADNestedGroupMembers  isn't found in power shell. I did find a ps1 script called "Get-ADNestedGroupMembers.ps1". If this is used, how do I run it using your syntax?
0
Mark LoganCommented:
Try this

Get-ADGroupMember "Group name" | where objectclass -eq "user" | select-object name | out-file "c:\nested.txt"
$groups = Get-ADGroupMember "Group name" | where objectclass -eq "group"
foreach ($group in $groups) {
Get-ADGroupMember "$group" |  select-object name | out-file -Append "c:\nested.txt"
}
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

rdefinoAuthor Commented:
I tried "Get-ADGroupMember "Group name" | where objectclass -eq "user" | select-object name | out-file "c:\nested.txt""

and it just dumped the members, not the members of the nested groups.

How do I run:

$groups = Get-ADGroupMember BulkMail-PowerUsers | where objectclass -eq "group"
foreach ($group in $groups) {
Get-ADGroupMember "$group" |  select-object name | out-file -Append "c:\BulkMail-PowerUsers_nested.txt"
}


thanks
0
ZenVenkyArchitectCommented:
Easiest way is to use Net or DSQuery commands to do it.

net group “Group Name” /domain >> C:\memberlist.txt

dsquery group DC=consoto,DC=com -name groupname | dsget group -members >> C:\groupname.txt


dsquery group -name “Group Name” | dsget group -members >> C:\memberlist.txt
0
Mark LoganCommented:
Just paste the whole of the text into Powershell and press enter (after attributing your group name) and it will do it all of you.  The second portion of the script queries the groups that are nested within the parent group, and queries the members of them and outputs them to the same text file.
0
rdefinoAuthor Commented:
MArk,

Do I need to put the group name in where i see "group" ?

$groups = Get-ADGroupMember BulkMail-PowerUsers | where objectclass -eq "group"
foreach ($group in $groups) {
Get-ADGroupMember "$group" |  select-object name | out-file -Append "c:\BulkMail-PowerUsers_nested.txt"
}
0
Mark LoganCommented:
No, group defines the object type.  The only thing that you should substitute is "Group Name" and your file path if you choose
0
Mark LoganCommented:
Did that work in the end?
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Active Directory

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.