Link to home
Start Free TrialLog in
Avatar of Flounder
Flounder

asked on

Need a script to export group membership and user names from Active Directory

I have a request to pull a list from Active Directory of First and Last names from a list of usernames and list users in a list of AD groups.

Does anyone have a script for the following?
1. Based on a list of usernames in a text file, Query First and Last names to a .csv
2. Export group membership to a .csv
Thanks.
Avatar of Mahesh
Mahesh
Flag of India image

For Groups, you can use within Powershell AD Module

PowerShell
Import-Module activedirectory
Get-ADGroupMember -Identity <GroupName> | Select Name, sAMAccountName | Export-csv <Csv file path>

You can create excel file with concatenate function for all groups and add output of this excel file in .ps1 file

Example
Powershell
import-module activedirectory
Get-ADGroupMember -Identity Group1 | Select Name, SamAccountName | Export-csv C:\group1.csv
Get-ADGroupMember -Identity Group2 | Select Name, SamAccountName | Export-csv C:\group2.csv

Open in new window


For list of users you can use Bulk AD users from WiseSoft, a free tool which can give you output based on list
ASKER CERTIFIED SOLUTION
Avatar of RobSampson
RobSampson
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Flounder
Flounder

ASKER

Exactly what I needed.  Thank you.