[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

AD Group Membership Export to File

Posted on 2009-04-21
6
Medium Priority
?
1,309 Views
Last Modified: 2013-12-24
I need to export the members of a distribution list within AD to a file.
I can see it can be done and has been posted before, but I can't seem to get the syntax right for my situation.

I need the contents of the DL called Coins Users
which is in (from the root) \UK\Distribution Lists\

Any advice?
I can see there is either a VBScript, or dsget
0
Comment
Question by:Stuart Oram
6 Comments
 
LVL 4

Expert Comment

by:JDominguezNY
ID: 24195208
If the objects are all directly in the Coin Users OU and not subdivided you can just right click that OU and choose Export List.

You will be able to save the list of all objects in that OU as a text file.
0
 
LVL 57

Accepted Solution

by:
Mike Kline earned 1600 total points
ID: 24195298
download the latest version of adfind (what I like using)
http://www.joeware.net/freetools/tools/adfind/index.htm
Then run this command
adfind -default -f name="coins users" -dsq | adfind -s base -asq member samaccountname
I created a "coins users" group in my lab and put one user in it to test the command (see screenshot)
Thanks
Mike

coinsusers.jpg
0
 
LVL 57

Assisted Solution

by:Mike Kline
Mike Kline earned 1600 total points
ID: 24195370
Follow up to export it use
adfind -default -f name="coins users" -dsq | adfind -s base -asq member samaccountname -csv > c:\coinsusers.csv
will save a csv file on your c drive called coinsusers.csv
Thanks
Mike
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 1

Assisted Solution

by:Joemonkey
Joemonkey earned 400 total points
ID: 24196467
I use this vbscript, just change PUTDOMAINHERE to whatever your domain is, and change the file path/name if you want.  When you run this script it will prompt you for the user's samaccountname
'~~Script~~.
Option Explicit
Dim Group
Dim GroupName
Dim GroupDomain
Dim Member
Dim w
Dim ws
 
const ForReading = 1
const ForWriting = 2
const ForAppending = 8
Const TristateFalse = 0
 
GroupDomain = "PUTDOMAINHERE"
GroupName = InputBox ("Group Name to list Members:","Enter GroupName")
  if GroupName = "" then
  wscript.quit
  end if
 
Set ws = CreateObject ("Scripting.FileSystemObject")
Set w = ws.OpenTextFile ("C:\temp\" & GroupName & " members.txt",ForAppending, True)
 
Set Group = GetObject("WinNT://" & GroupDomain & "/" & GroupName & ",group")
 
For Each Member in Group.Members
  w.WriteLine Member.Name
Next
Wscript.Echo "Text file C:\temp\" & GroupName & " members.txt contains the list of users in this group."

Open in new window

0
 
LVL 1

Assisted Solution

by:Joemonkey
Joemonkey earned 400 total points
ID: 24196503
In my above comment:

it will prompt you for the user's samaccountname

should read

it will prompt you for the AD group name

Sorry :)
0
 
LVL 1

Author Closing Comment

by:Stuart Oram
ID: 31572798
Gave the most points to the one I used, but split points as appreciation of other posted solution!
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

In this article, I’ll look at how you can use a backup to start a secondary instance for MongoDB.
Instead of error trapping or hard-coding for non-updateable fields when using QODBC, let VBA automatically disable them when forms open. This way, users can view but not change the data. Part 1 explained how to use schema tables to do this. Part 2 h…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …

873 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