Afficher un message
Vieux 05/10/2007, 22h15   #2
Richard Mueller [MVP]
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Scripting in 2003 Active Directory

gram wrote:

> We need a script to change about 100 users profile paths in 2003 AD,
> instead
> of doing it manually.
>
> The only change is the servername, rest of path is ok.
>
> can anyone point me to a website or to a script that will do this?
>


I have an example VBScript program to change profilePath for users in bulk
from a spreadsheet linked here:

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

The spreadsheet should have user Distinguished Names in the first column and
the new profilePath in the second column. There is also a link above to a
program to create the spreadsheet with user Distinguished Names in the first
column. You can modify that program, CreateUserList3.vbs, to add the
existing value of profilePath to the second column. To do this add the
additional attribute name to the comma delimited list in the query
statement. The existing statement is:
===========
strQuery = "<LDAP://" & strDNSDomain & ">;" & strFilter _
& ";distinguishedName;subtree"
============
This should be revised to:
=======
strQuery = "<LDAP://" & strDNSDomain & ">;" & strFilter _
& ";distinguishedName,profilePath;subtree"
=========
Then in the loop where the recordset is enumerated, add statements to write
profilePath in the second column of the spreadsheet. The complete loop would
be:
=============
Dim strProfile

Do Until adoRecordset.EOF
strDN = adoRecordset.Fields("distinguishedName").Value
' Escape any forward slash characters, "/", with the backslash
' escape character. All other characters that should be escaped are.
strDN = Replace(strDN, "/", "\/")
objSheet.Cells(k, 1).Value = strDN
strProfile = adoRecordset.Fields("profilePath").Value
objSheet.Cells(k, 2).Value = strProfile
k = k + 1
adoRecordset.MoveNext
Loop
============
Note I also added a "Dim" statement to declare the new variable
"strProfile". This is needed because the script uses "Option Explicit".

Using a spreadsheet allows you to manipulate the values any way you wish.
Replacing the server name throughout should be easy. You can also delete
rows for users that should not be modified.

The program CreateUserList3.vbs documents all users in the domain. If your
users are just in one OU, change the base of the query in that program to
specify the Distinguished Name of the domain. Instead of strDNSDomain above,
use the Distinguished Name of your OU. Then only users in the OU are
documented in the spreadsheet.

Once the spreadsheet is complete, run UpdateUserProfile.vbs linked above.

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


  Réponse avec citation
 
Page generated in 0,15780 seconds with 9 queries