Results 1 to 4 of 4

Thread: export account details from an OU

  1. #1
    Join Date
    Oct 2004
    Posts
    62

    export account details from an OU

    Hey guys I need some urgent help from you all. Due to some reasons I need to export a data of my OU to CSV format. Let me tell you that this OU also contains some more OU’s which I also need to be exported. As I have never done this before, can anyone please tell me what the easiest way for doing the same is? Also can somebody please tell if I can choose only one OU or everything included in this OU can be exported?

    Many thanks.

  2. #2
    Join Date
    Sep 2004
    Posts
    110

    RE: export account details from an OU

    Yes, it is possible. Just try out the following (queries all users under the "sales" OU and sub-OUs):

    On Error Resume Next

    Const ADS_SCOPE_SUBTREE = 2
    Const FOR_WRITING = 2
    outFile = ".\Users.csv"

    Set objConnection = CreateObject("ADODB.Connection")
    Set objCommand = CreateObject("ADODB.Command")
    objConnection.Provider = "ADsDSOObject"
    objConnection.Open "Active Directory Provider"
    Set objCommand.ActiveConnection = objConnection
    Set objFSO = CreateObject("Scripting.FileSystemObject")

    objCommand.Properties("Page Size") = 1000
    objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE

    objCommand.CommandText = _
    "SELECT Name FROM 'LDAP://ou=sales,dc=fabrikam,dc=com' WHERE
    objectCategory='user'"
    Set objRecordSet = objCommand.Execute

    Set objOut = objFSO.CreateTextFile(outFile, FOR_WRITING)

    objRecordSet.MoveFirst
    Do Until objRecordSet.EOF
    Wscript.Echo objRecordSet.Fields("Name").Value
    objOut.Writeline objRecordSet.Fields("Name").Value
    objRecordSet.MoveNext
    Loop

  3. #3
    Join Date
    Oct 2004
    Posts
    62

    Re: export account details from an OU

    Thank you very much for the help Chapal but as being the first time, can you please also tell me where do i need to run this query?

    Thanks again.

  4. #4
    Join Date
    Sep 2004
    Posts
    110

    Re: export account details from an OU

    There is no specific place to run this, you can simply run it on any workstations authenticated to the domain. It will create a file named Users.csv. But the best way I can suggest you is to run this in a command prompt with the cscript host. For example, if
    the script is saved in the file GetUsers.vbs (the file must have the *.vbs extension), you can use the following command at a command prompt:

    cscript GetUsers.vbs

Similar Threads

  1. Hotmail Spam - Asking for Account Details
    By Hardik in forum Networking & Security
    Replies: 1
    Last Post: 03-08-2011, 05:07 PM
  2. export details in active directory to Access 2003
    By hz84 in forum Active Directory
    Replies: 1
    Last Post: 21-05-2011, 06:56 AM
  3. Stuck on a guest account, cannot access windows 7 admin account
    By LavaStones in forum Windows Software
    Replies: 1
    Last Post: 11-02-2011, 10:49 PM
  4. Export Outlook Express Account Settings on Windows mail
    By afidelino in forum Operating Systems
    Replies: 5
    Last Post: 24-02-2009, 07:38 PM
  5. No Folder Size in Details Pane or Details View ?!
    By Synapse Syndrome in forum Vista Help
    Replies: 12
    Last Post: 01-11-2008, 10:22 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,461,254.18211 seconds with 17 queries