in active directory users and computers, on a user object, there is a
"profile" tab. on this tab is the option to map a drive to a path on a
server share. i have 6,000 users that all have the same server name in that
box and i need to change them all to a different server. for the time being
im using a DNS workaround to point the old name to the new server, but i
have to do it right. so... anyone have a quick fix? any help is appreciated.
thank you

Re: active directory scripting question.... by Richard

Richard
Wed Jun 22 20:03:49 CDT 2005


> in active directory users and computers, on a user object, there is a
> "profile" tab. on this tab is the option to map a drive to a path on a
> server share. i have 6,000 users that all have the same server name in
that
> box and i need to change them all to a different server. for the time
being
> im using a DNS workaround to point the old name to the new server, but i
> have to do it right. so... anyone have a quick fix? any help is
appreciated.
> thank you

Hi,

If you mean the "Home Folder" settings, the two attributes are homeDrive and
homeDirectory. If you mean the "Profile Path", the attribute is profilePath
(the "Logon Script" setting is scriptPath). A VBScript program would be a
good way to modify these settings.

If you are changing homeDirectory, you could code a script that uses ADO to
retrieve the Distinguished Name (DN) and homeDirectory attributes for all
users. This would return a recordset, one record for each user. ADO cannot
update AD, but you could bind to each user object (using the DN), replace
the server name in homeDirectory, assign the new value, and invoke SetInfo
to commit the change. This would be repeated for each user (in the loop
where you enumerate the recordset).

Because of the chance of unintended results, I like to do such things in two
steps. First, I export all users to a text file or spreadsheet. ADO can be
used to retrieve DN and homeDirectory for all users. Then you can import the
text file or open the spreadsheet and manipulate as desired. You can delete
users that should not be modified and modify the homeDirectory value for the
rest. Then a second program would read the modified spreadsheet and make the
changes.

A program to dump all user DN's to a spreadsheet is linked on this page:

http://www.rlmueller.net/Create%20User%20List%203.htm

To modify this to also retrieve homeDirectory, make the following changes:

1. Add the homeDirectory attribute to the comma delimited list of attributes
to be retrieved. For example:

strQuery = "<LDAP://" & strDNSDomain & ">;" & strFilter _
& ";distinguishedName,homeDirectory;subtree"

2. In the loop that enumerates the recordset, add steps to retrieve the
value of homeDirectory and write the value to the spreadsheet. I declare a
new variable called strHome for the homeDirectory value:

Dim strHome
Do Until objRecordSet.EOF
strDN = objRecordSet.Fields("distinguishedName")
strHome = objRecordset.Fields("homeDirectory")
objSheet.Cells(k, 1).Value = strDN
objSheet.Cells(k, 2).Value = strHome
k = k + 1
objRecordSet.MoveNext
Loop

The value of DN is written to in the first column, homeDirectory in the
second column.

Next, you need a program to read this spreadsheet (after you modify it) and
update the users. I have a similar example VBScript program linked here:

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

This program updates the userProfile attribute of users per an Excel
spreadsheet. If you are modifying homeDirectory, just replace "userProfile"
with "homeDirectory" throughout. This program assumes the user DN is in the
first column, the attribute to be modified is in the second column. Both
programs skip the first row, which is assumed to have column headings.

For more info on using ADO to retrieve info from AD, see this link:

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

--
Richard
Microsoft MVP Scripting and ADSI
Hilltop Lab web site - http://www.rlmueller.net
--



Re: active directory scripting question.... by no

no
Thu Jun 23 04:30:32 CDT 2005

wow. i feel like i should pay you for that one!
thank you very much. i actually have a lab environment that mimics my
production environment at all times. so i can play around as much as i need.
thank you again!




"Richard Mueller [MVP]" <rlmueller-NOSPAM@ameritech.NOSPAM.net> wrote in
message news:evDab$4dFHA.2960@TK2MSFTNGP10.phx.gbl...
>
>> in active directory users and computers, on a user object, there is a
>> "profile" tab. on this tab is the option to map a drive to a path on a
>> server share. i have 6,000 users that all have the same server name in
> that
>> box and i need to change them all to a different server. for the time
> being
>> im using a DNS workaround to point the old name to the new server, but i
>> have to do it right. so... anyone have a quick fix? any help is
> appreciated.
>> thank you
>
> Hi,
>
> If you mean the "Home Folder" settings, the two attributes are homeDrive
> and
> homeDirectory. If you mean the "Profile Path", the attribute is
> profilePath
> (the "Logon Script" setting is scriptPath). A VBScript program would be a
> good way to modify these settings.
>
> If you are changing homeDirectory, you could code a script that uses ADO
> to
> retrieve the Distinguished Name (DN) and homeDirectory attributes for all
> users. This would return a recordset, one record for each user. ADO cannot
> update AD, but you could bind to each user object (using the DN), replace
> the server name in homeDirectory, assign the new value, and invoke SetInfo
> to commit the change. This would be repeated for each user (in the loop
> where you enumerate the recordset).
>
> Because of the chance of unintended results, I like to do such things in
> two
> steps. First, I export all users to a text file or spreadsheet. ADO can be
> used to retrieve DN and homeDirectory for all users. Then you can import
> the
> text file or open the spreadsheet and manipulate as desired. You can
> delete
> users that should not be modified and modify the homeDirectory value for
> the
> rest. Then a second program would read the modified spreadsheet and make
> the
> changes.
>
> A program to dump all user DN's to a spreadsheet is linked on this page:
>
> http://www.rlmueller.net/Create%20User%20List%203.htm
>
> To modify this to also retrieve homeDirectory, make the following changes:
>
> 1. Add the homeDirectory attribute to the comma delimited list of
> attributes
> to be retrieved. For example:
>
> strQuery = "<LDAP://" & strDNSDomain & ">;" & strFilter _
> & ";distinguishedName,homeDirectory;subtree"
>
> 2. In the loop that enumerates the recordset, add steps to retrieve the
> value of homeDirectory and write the value to the spreadsheet. I declare a
> new variable called strHome for the homeDirectory value:
>
> Dim strHome
> Do Until objRecordSet.EOF
> strDN = objRecordSet.Fields("distinguishedName")
> strHome = objRecordset.Fields("homeDirectory")
> objSheet.Cells(k, 1).Value = strDN
> objSheet.Cells(k, 2).Value = strHome
> k = k + 1
> objRecordSet.MoveNext
> Loop
>
> The value of DN is written to in the first column, homeDirectory in the
> second column.
>
> Next, you need a program to read this spreadsheet (after you modify it)
> and
> update the users. I have a similar example VBScript program linked here:
>
> http://www.rlmueller.net/UpdateUserProfile.htm
>
> This program updates the userProfile attribute of users per an Excel
> spreadsheet. If you are modifying homeDirectory, just replace
> "userProfile"
> with "homeDirectory" throughout. This program assumes the user DN is in
> the
> first column, the attribute to be modified is in the second column. Both
> programs skip the first row, which is assumed to have column headings.
>
> For more info on using ADO to retrieve info from AD, see this link:
>
> http://www.rlmueller.net/ADOSearchTips.htm
>
> --
> Richard
> Microsoft MVP Scripting and ADSI
> Hilltop Lab web site - http://www.rlmueller.net
> --
>
>