Go Back   TechArena Community > Technical Support > Computer Help > Windows Server > Active Directory
Become a Member!
Forgot your username/password?
Register Tags Active Topics RSS Search Mark Forums Read SiteMap

Tags: , ,

Sponsored Links



export account details from an OU

Active Directory


Reply
 
Thread Tools Search this Thread
  #1  
Old 14-10-2008
Cyborg
 
Posts: n/a
export account details from an OU

Hi,

I need to export users from an OU to a CSV, this OU contains some more OU's
that I also need the users exported from, how can I easiliy achieve this?

Not sure if I can choose one OU and everything under this OU can be
exported?

Thanks

Reply With Quote
  #2  
Old 14-10-2008
Salvador Manaois III
 
Posts: n/a
RE: export account details from an OU

Please try this (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

--
Salvador Manaois III
MCSE MCSA CEH MCITP | Enterprise/Server Admin
Bytes & Badz : http://badzmanaois.blogspot.com


"Cyborg" wrote:

> Hi,
>
> I need to export users from an OU to a CSV, this OU contains some more OU's
> that I also need the users exported from, how can I easiliy achieve this?
>
> Not sure if I can choose one OU and everything under this OU can be
> exported?
>
> Thanks
>
>

Reply With Quote
  #3  
Old 14-10-2008
Cyborg
 
Posts: n/a
Re: export account details from an OU

Hi, where do I run this?


"Salvador Manaois III" <SalvadorManaoisIII@discussions.microsoft.com> wrote
in message news:C86D70BB-ED1B-4F37-A418-6024F8563EE1@microsoft.com...
> Please try this (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
>
> --
> Salvador Manaois III
> MCSE MCSA CEH MCITP | Enterprise/Server Admin
> Bytes & Badz : http://badzmanaois.blogspot.com
>
>
> "Cyborg" wrote:
>
>> Hi,
>>
>> I need to export users from an OU to a CSV, this OU contains some more
>> OU's
>> that I also need the users exported from, how can I easiliy achieve this?
>>
>> Not sure if I can choose one OU and everything under this OU can be
>> exported?
>>
>> Thanks
>>
>>


Reply With Quote
  #4  
Old 14-10-2008
Richard Mueller [MVP]
 
Posts: n/a
Re: export account details from an OU

The script can be run on any computer authenticated to the domain. The
script creates the file Users.csv.

I would run it at 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

This assumes you are in the folder where the file GetUsers.vbs is saved. If
not, you must specify the path and file name. The file Users.csv is created
in the same folder.

--
Richard Mueller
MVP Directory Services
Hilltop Lab - http://www.rlmueller.net
--

"Cyborg" <apollo13@btinternet.com> wrote in message
news:CB09A36A-435E-42AB-941A-74060EFC3554@microsoft.com...
> Hi, where do I run this?
>
>
> "Salvador Manaois III" <SalvadorManaoisIII@discussions.microsoft.com>
> wrote in message
> news:C86D70BB-ED1B-4F37-A418-6024F8563EE1@microsoft.com...
>> Please try this (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
>>
>> --
>> Salvador Manaois III
>> MCSE MCSA CEH MCITP | Enterprise/Server Admin
>> Bytes & Badz : http://badzmanaois.blogspot.com
>>
>>
>> "Cyborg" wrote:
>>
>>> Hi,
>>>
>>> I need to export users from an OU to a CSV, this OU contains some more
>>> OU's
>>> that I also need the users exported from, how can I easiliy achieve
>>> this?
>>>
>>> Not sure if I can choose one OU and everything under this OU can be
>>> exported?
>>>
>>> Thanks
>>>
>>>

>



Reply With Quote
Reply

  TechArena Community > Technical Support > Computer Help > Windows Server > Active Directory


Thread Tools Search this Thread
Search this Thread:

Advanced Search


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


All times are GMT +5.5. The time now is 01:55 AM.