Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

getting members of groups | active directory | powershell

Posted on 2014-12-20
5
180 Views
Last Modified: 2014-12-20
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
0
Comment
Question by:cmatchett
  • 3
5 Comments
 
LVL 57

Expert Comment

by:Mike Kline
ID: 40510771
What text are you looking for? Is it  in the group name or some other text?

Thanks

Mike
0
 

Author Comment

by:cmatchett
ID: 40510775
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
 
LVL 69

Accepted Solution

by:
Qlemo earned 500 total points
ID: 40510859
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

Open in new window

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

Author Comment

by:cmatchett
ID: 40510884
thank you Qlemo, a job well done
0
 

Author Closing Comment

by:cmatchett
ID: 40510997
excellent
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article outlines the process to identify and resolve account lockout in an Active Directory environment.
The Nano Server Image Builder helps you create a custom Nano Server image and bootable USB media with the aid of a graphical interface. Based on the inputs you provide, it generates images for deployment and creates reusable PowerShell scripts that …
This tutorial will walk an individual through the process of transferring the five major, necessary Active Directory Roles, commonly referred to as the FSMO roles to another domain controller. Log onto the new domain controller with a user account t…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

808 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question