# getting members of groups | active directory | powershell

Hi Experts,

I would like to search for all groups that have a certain text in it.

i would like to export the members of each group to a CSV

in the CSV, i would like to have the name of the group that the user is a member of.  So, my columns would be samaccountname, group
###### Who is Participating?

Batchelor and DeveloperCommented:
Using the Active Directory module, and shown for domain admins:
get-adgroup -filter "name -like 'dom*admi*'" | % {
get-adgroupmember $_ | add-member NoteProperty Group$_.name -passThru -force
} | select samAccountName, Group, Name | export-csv -NoType C:\temp\ee\groupmembers.csv

I've added the full name to the output.
0

Commented:
What text are you looking for? Is it  in the group name or some other text?

Thanks

Mike
0

Author Commented:
Hi Mike,

there are multiple groups that have a similar name and i would like to export all the users of these groups.  In the output, have the group that the user is a member of along with the username
0

Author Commented:
thank you Qlemo, a job well done
0

Author Commented:
excellent
0
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.