Solved

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

Posted on 2014-12-16
4
30 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 36

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

Manage your data center from practically anywhere

The KN8164V features HD resolution of 1920 x 1200, FIPS 140-2 with level 1 security standards and virtual media transmissions at twice the speed. Built for reliability, the KN series provides local console and remote over IP access, ensuring 24/7 availability to all servers.

Question has a verified solution.

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

Restoring deleted objects in Active Directory has been a standard feature in Active Directory for many years, yet some admins may not know what is available.
With User Account Control (UAC) enabled in Windows 7, one needs to open an elevated Command Prompt in order to run scripts under administrative privileges. Although the elevated Command Prompt accomplishes the task, the question How to run as script…
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 video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

828 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