Solved

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

Posted on 2014-12-16
4
24 Views
Last Modified: 2016-06-16
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.
0
Comment
Question by:Flounder
4 Comments
 
LVL 35

Expert Comment

by:Mahesh
ID: 40504753
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
0
 
LVL 65

Accepted Solution

by:
RobSampson earned 500 total points
ID: 40506309
Hi Flounder, there's an old script here that I just dug up, that might give you what you need as well:
http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_23974628.html

Regards,

Rob.
1
 

Author Comment

by:Flounder
ID: 40508299
Exactly what I needed.  Thank you.
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

Suggested Solutions

Title # Comments Views Activity
How do i move AD Contacts to O365? 2 31
Question to the line 4 38
Cloud to Hybrid 4 14
GPO help required 12 27
If you get continual lockouts after changing your Active Directory password, there are several possible reasons.  Two of the most common are using other devices to access your email and stored passwords in the credential manager of windows.
Join Greg Farro and Ethan Banks from Packet Pushers (http://packetpushers.net/podcast/podcasts/pq-show-93-smart-network-monitoring-paessler-sponsored/) and Greg Ross from Paessler (https://www.paessler.com/prtg) for a discussion about smart network …
Windows 8 comes with a dramatically different user interface known as Metro. Notably missing from the new interface is a Start button and Start Menu. Many users do not like it, much preferring the interface of earlier versions — Windows 7, Windows X…
This tutorial will walk an individual through the steps necessary to join and promote the first Windows Server 2012 domain controller into an Active Directory environment running on Windows Server 2008. Determine the location of the FSMO roles by lo…

932 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now