Jump to content

Exporting user info


Recommended Posts

Guest Glenn Clark
Posted

Hi All

 

I am about to do an upgrade form sbs2000 to 2003 and need to export AD user

data. I have managed to find a script which tells me all the email addresses

but I need to export a full list of users which tell me their drive letter

and location for mapped home folder and what login script is set for them.

Is there an easy way I can get this information exported

 

Many thanks

 

Glenn

  • Replies 3
  • Created
  • Last Reply

Popular Days

Guest Meinolf Weber
Posted

Re: Exporting user info

 

Hello Glenn,

 

I strongly recommend to post to:

microsoft.public.windows.server.sbs

 

I think you can do a kind of inplace upgrade, but ask there, you have the

SBS experts in that NG.

 

Best regards

 

Meinolf Weber

Disclaimer: This posting is provided "AS IS" with no warranties, and confers

no rights.

** Please do NOT email, only reply to Newsgroups

** HELP us help YOU!!! http://www.blakjak.demon.co.uk/mul_crss.htm

 

> Hi All

>

> I am about to do an upgrade form sbs2000 to 2003 and need to export AD

> user data. I have managed to find a script which tells me all the

> email addresses but I need to export a full list of users which tell

> me their drive letter and location for mapped home folder and what

> login script is set for them. Is there an easy way I can get this

> information exported

>

> Many thanks

>

> Glenn

>

Guest Richard Mueller [MVP]
Posted

Re: Exporting user info

 

 

"Glenn Clark" <NOSPAMPLEASEglenn.btn@gmail.comNOSPAMPLEASE> wrote in message

news:uAsNCasKJHA.5460@TK2MSFTNGP03.phx.gbl...

> Hi All

>

> I am about to do an upgrade form sbs2000 to 2003 and need to export AD

> user data. I have managed to find a script which tells me all the email

> addresses but I need to export a full list of users which tell me their

> drive letter and location for mapped home folder and what login script is

> set for them. Is there an easy way I can get this information exported

>

> Many thanks

>

> Glenn

>

 

The attribute values you refer to are homeDrive, homeDirectory, and

scriptPath. You also want distinguishedName (or DN) and sAMAccountName

(pre-Windows 2000 logon name). You can use Joe Richards' free adfind command

line utility to export these values for all users.

 

http://www.joeware.net/freetools/tools/adfind/index.htm

 

You could also use the command line tools dsquery and dsget. Otherwise, the

following VBScript program outputs the values for all users. It should be

run at a command prompt with the output redirected to a text file. For

example, if the code is saved in a text file called GetUsers.vbs, you could

use the command:

 

cscript //nologo GetUsers.vbs > report.csv

 

This assumes you are in the folder were GetUsers.vbs is saved. Otherwise,

you must also specify the path to the *.vbs file. The output is saved in

report.csv, which can be read into a spreadsheet. The VBScript program

follows:

=========

Option Explicit

 

Dim objRootDSE, strDNSDomain, adoCommand, adoConnection

Dim strBase, strFilter, strAttributes, strQuery, adoRecordset

Dim strDN, strNTName, strHomeDir, strHomeDrive, strScript

Dim arrAttrValues

 

' Determine DNS domain name.

Set objRootDSE = GetObject("LDAP://RootDSE")

strDNSDomain = objRootDSE.Get("defaultNamingContext")

 

' Use ADO to search Active Directory.

Set adoCommand = CreateObject("ADODB.Command")

Set adoConnection = CreateObject("ADODB.Connection")

adoConnection.Provider = "ADsDSOObject"

adoConnection.Open "Active Directory Provider"

adoCommand.ActiveConnection = adoConnection

 

' Search entire domain.

strBase = "<LDAP://" & strDNSDomain & ">"

 

' Search for all users.

strFilter = "(&(objectCategory=person)(objectClass=user))"

 

' Comma delimited list of attribute values to retrieve.

strAttributes = "distinguishedName,sAMAccountName," _

& "homeDirectory,homeDrive,scriptPath"

 

' Construct the LDAP query.

strQuery = strBase & ";" & strFilter & ";" & strAttributes & ";subtree"

 

' Run the query.

adoCommand.CommandText = strQuery

adoCommand.Properties("Page Size") = 100

adoCommand.Properties("Timeout") = 30

adoCommand.Properties("Cache Results") = False

Set adoRecordset = adoCommand.Execute

 

' Output heading line.

Wscript.Echo """Distinguished Name"",""NT Name"",""Home Directory""," _

& """Home Drive"",""Logon Script"""

 

' Enumerate the resulting recordset.

Do Until adoRecordset.EOF

' Retrieve single-valued strings.

strDN = adoRecordset.Fields("distinguishedName").Value

strNTName = adoRecordset.Fields("sAMAccountName").Value

strHomeDir = adoRecordset.Fields("homeDirectory").Value

strHomeDrive = adoRecordset.Fields("homeDrive").Value

strScript = adoRecordset.Fields("scriptPath").Value

 

' Create array of string values to display.

arrAttrValues = Array(strDN, strNTName, strHomeDir, _

strHomeDrive, strScript)

 

' Display array of values in a comma delimited line, with each

' value enclosed in quotes.

Wscript.Echo CSVLine(arrAttrValues)

 

' Move to next record in recordset.

adoRecordset.MoveNext

Loop

 

' Clean up.

adoRecordset.Close

adoConnection.Close

 

Function CSVLine(ByVal arrValues)

' Function to convert array of values into comma delimited

' values enclosed in quotes.

Dim strItem

 

CSVLine = ""

For Each strItem In arrValues

' Replace any embedded quotes with two quotes.

If (strItem <> "") Then

strItem = Replace(strItem, """", """" & """")

End If

' Append string values, enclosed in quotes,

' delimited by commas.

If (CSVLine = "") Then

CSVLine = """" & strItem & """"

Else

CSVLine = CSVLine & ",""" & strItem & """"

End If

Next

 

End Function

=========

If you have Exchange, email addresses are in the multi-valued attribute

proxyAddresses. This can also be exported, but you say you have already have

a script that does this. Email addresses can also be in the mail attribute.

The above script is based on the following example, which also shows how to

handle multi-valued attributes (like proxyAddresses):

 

http://www.rlmueller.net/DocumentUsers.htm

 

--

Richard Mueller

MVP Directory Services

Hilltop Lab - http://www.rlmueller.net

--

Guest Glenn Clark
Posted

Re: Exporting user info

 

Thanks that's brilliant

 

Glenn

 

"Richard Mueller [MVP]" <rlmueller-nospam@ameritech.nospam.net> wrote in

message news:u453PAtKJHA.4324@TK2MSFTNGP05.phx.gbl...

>

> "Glenn Clark" <NOSPAMPLEASEglenn.btn@gmail.comNOSPAMPLEASE> wrote in

> message news:uAsNCasKJHA.5460@TK2MSFTNGP03.phx.gbl...

>> Hi All

>>

>> I am about to do an upgrade form sbs2000 to 2003 and need to export AD

>> user data. I have managed to find a script which tells me all the email

>> addresses but I need to export a full list of users which tell me their

>> drive letter and location for mapped home folder and what login script is

>> set for them. Is there an easy way I can get this information exported

>>

>> Many thanks

>>

>> Glenn

>>

>

> The attribute values you refer to are homeDrive, homeDirectory, and

> scriptPath. You also want distinguishedName (or DN) and sAMAccountName

> (pre-Windows 2000 logon name). You can use Joe Richards' free adfind

> command line utility to export these values for all users.

>

> http://www.joeware.net/freetools/tools/adfind/index.htm

>

> You could also use the command line tools dsquery and dsget. Otherwise,

> the following VBScript program outputs the values for all users. It should

> be run at a command prompt with the output redirected to a text file. For

> example, if the code is saved in a text file called GetUsers.vbs, you

> could use the command:

>

> cscript //nologo GetUsers.vbs > report.csv

>

> This assumes you are in the folder were GetUsers.vbs is saved. Otherwise,

> you must also specify the path to the *.vbs file. The output is saved in

> report.csv, which can be read into a spreadsheet. The VBScript program

> follows:

> =========

> Option Explicit

>

> Dim objRootDSE, strDNSDomain, adoCommand, adoConnection

> Dim strBase, strFilter, strAttributes, strQuery, adoRecordset

> Dim strDN, strNTName, strHomeDir, strHomeDrive, strScript

> Dim arrAttrValues

>

> ' Determine DNS domain name.

> Set objRootDSE = GetObject("LDAP://RootDSE")

> strDNSDomain = objRootDSE.Get("defaultNamingContext")

>

> ' Use ADO to search Active Directory.

> Set adoCommand = CreateObject("ADODB.Command")

> Set adoConnection = CreateObject("ADODB.Connection")

> adoConnection.Provider = "ADsDSOObject"

> adoConnection.Open "Active Directory Provider"

> adoCommand.ActiveConnection = adoConnection

>

> ' Search entire domain.

> strBase = "<LDAP://" & strDNSDomain & ">"

>

> ' Search for all users.

> strFilter = "(&(objectCategory=person)(objectClass=user))"

>

> ' Comma delimited list of attribute values to retrieve.

> strAttributes = "distinguishedName,sAMAccountName," _

> & "homeDirectory,homeDrive,scriptPath"

>

> ' Construct the LDAP query.

> strQuery = strBase & ";" & strFilter & ";" & strAttributes & ";subtree"

>

> ' Run the query.

> adoCommand.CommandText = strQuery

> adoCommand.Properties("Page Size") = 100

> adoCommand.Properties("Timeout") = 30

> adoCommand.Properties("Cache Results") = False

> Set adoRecordset = adoCommand.Execute

>

> ' Output heading line.

> Wscript.Echo """Distinguished Name"",""NT Name"",""Home Directory""," _

> & """Home Drive"",""Logon Script"""

>

> ' Enumerate the resulting recordset.

> Do Until adoRecordset.EOF

> ' Retrieve single-valued strings.

> strDN = adoRecordset.Fields("distinguishedName").Value

> strNTName = adoRecordset.Fields("sAMAccountName").Value

> strHomeDir = adoRecordset.Fields("homeDirectory").Value

> strHomeDrive = adoRecordset.Fields("homeDrive").Value

> strScript = adoRecordset.Fields("scriptPath").Value

>

> ' Create array of string values to display.

> arrAttrValues = Array(strDN, strNTName, strHomeDir, _

> strHomeDrive, strScript)

>

> ' Display array of values in a comma delimited line, with each

> ' value enclosed in quotes.

> Wscript.Echo CSVLine(arrAttrValues)

>

> ' Move to next record in recordset.

> adoRecordset.MoveNext

> Loop

>

> ' Clean up.

> adoRecordset.Close

> adoConnection.Close

>

> Function CSVLine(ByVal arrValues)

> ' Function to convert array of values into comma delimited

> ' values enclosed in quotes.

> Dim strItem

>

> CSVLine = ""

> For Each strItem In arrValues

> ' Replace any embedded quotes with two quotes.

> If (strItem <> "") Then

> strItem = Replace(strItem, """", """" & """")

> End If

> ' Append string values, enclosed in quotes,

> ' delimited by commas.

> If (CSVLine = "") Then

> CSVLine = """" & strItem & """"

> Else

> CSVLine = CSVLine & ",""" & strItem & """"

> End If

> Next

>

> End Function

> =========

> If you have Exchange, email addresses are in the multi-valued attribute

> proxyAddresses. This can also be exported, but you say you have already

> have a script that does this. Email addresses can also be in the mail

> attribute. The above script is based on the following example, which also

> shows how to handle multi-valued attributes (like proxyAddresses):

>

> http://www.rlmueller.net/DocumentUsers.htm

>

> --

> Richard Mueller

> MVP Directory Services

> Hilltop Lab - http://www.rlmueller.net

> --

>

>


×
×
  • Create New...