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?
QlemoConnect With a Mentor 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 $ -passThru -force
} | select samAccountName, Group, Name | export-csv -NoType C:\temp\ee\groupmembers.csv

Open in new window

I've added the full name to the output.
Mike KlineCommented:
What text are you looking for? Is it  in the group name or some other text?


cmatchettAuthor 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
cmatchettAuthor Commented:
thank you Qlemo, a job well done
cmatchettAuthor Commented:
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.

All Courses

From novice to tech pro — start learning today.