Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2014-12-16
4
Medium Priority
?
42 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 37

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 2000 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

A bad practice commonly found during an account life cycle is to set its password to an initial, insecure password. The Password Reset Tool was developed to make the password reset process easier and more secure.
Wouldn't it be nice if objects in Active Directory automatically moved into the correct Organizational Units? This is what AutoAD aims to do and as a plus, it automatically creates Sites, Subnets, and Organizational Units.
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

715 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