Solved

# getting members of groups | active directory | powershell

Posted on 2014-12-20
175 Views
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
Question by:cmatchett
• 3

LVL 57

Expert Comment

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

Thanks

Mike
0

Author Comment

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 68

Accepted Solution

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

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

Author Comment

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

Author Closing Comment

ID: 40510997
excellent
0

## Featured Post

Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
In this article, we will see the basic design consideration while designing a Multi-tenant web application in a simple manner. Though, many frameworks are available in the market to develop a multi - tenant application, but do they provide data, cod…
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 from a Windows Server 2008 domain controller to a Windows Server 2012 domain controlle…
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…