Navigation Menu

Friday, 19 June 2015

Get AD Group Members using Powershell

We can get the list of AD Group members using Active Directory Powershell cmdlet Get-ADGroupMember. In this article, I am going to write Powershell script to get list of AD Group members, export group members to CSV file and export AD groups and members to CSV file.

Run the following command to import Active Directory cmdlets.

Import-Module ActiveDirectory

Use the following Powershell command to get the list of specified AD Group members.

Export AD Group Members to CSV:

The following Powershell script gets a list of members of specified AD group and exports member details to CSV file. Replace the group name "Domain Admins" with your own group name in the below script.

Export AD Groups and Members to CSV:

The following PowerShell script gets a list of all Active Directory groups and its members. The Get-ADGroup cmdlet gets all the AD Groups and passed into ForEach-Object to get members of every AD Group. Finally it exports both group and member details to CSV file.