For each user the Street:State:Zipcode changes.For such cases i would required a script to do this.
Main Topics
Browse All TopicsHi,
I have a file which has these details.
Username:Street:State:Zipc
I need a script which can find this user and update these details in the ADS user properties > Address tab.
Is there a script which can do this.
Need results file to generate with succuess and failure.
REgards
Sharath
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Hi,
try using csvde to update the users, but then if you want to do it by script then you can do the following...
www.computerperformance.co
Also use the AD Schema to find out the user variables under the user class that you want to update.
The pseudo code is.
Dim define your variables
Connect to AD create a list of usernames
Connect the filesystem object to the text file
take first name in the AD
this bit is where you compare the username in the text file to the user name in the AD
If found then
Update the fields you want updated
Else
keep looking for user
End if
Loop
End of script
With that schematic you should be able to build your script looking at the examples provided in the sites I above.
(sorry I would write it for you, but then that would take me a little while over my lunch break)
If you need help, let me know.
Regards,
Pritesh
Hi Sharath,
Make a text file (C:\EmpInfo.txt) in notepad with following information:
Dn: CN=Farhan Kazi,OU=Accounts,DC=Traini
changetype: modify
replace: St
St: Sindh
-
Dn: CN=Farhan Kazi,OU=Accounts,DC=Traini
changetype: modify
replace: postalCode
postalCode: 75600
-
Dn: CN=Farhan Kazi,OU=Accounts,DC=Traini
changetype: modify
replace: c
c: PK
-
Dn: CN=Irfan Asim,OU=Finance,DC=Trainin
changetype: modify
replace: St
St: Victoria
-
Dn: CN=Farhan Kazi,OU=Finance,DC=Trainin
changetype: modify
replace: postalCode
postalCode: 3001
-
Dn: CN=Farhan Kazi,OU=Finance,DC=Trainin
changetype: modify
replace: c
c: AU
-
Note To Modify attributes in AD it is very important that the following format be followed for the import file, especially the "-" on a single line followed by a completely blank line on the next line.
After making EmpInfo.txt file with above information import it using LDIFDE utility.
Click Start -> Run -> Cmd.exe
LDIFDE -I -F C:\EmpInfo.txt
You need to change "DN" value as per your user account info and the values of St:, postalCode:, and c:
Following will change State to 'Sindh' for user Farhan Kazi
Dn: CN=Farhan Kazi,OU=Accounts,DC=Traini
changetype: modify
replace: St
St: Sindh
-
Following will change the postal code.
Dn: CN=Farhan Kazi,OU=Accounts,DC=Traini
changetype: modify
replace: postalCode
postalCode: 75600
-
Following will change the Country.
Dn: CN=Farhan Kazi,OU=Accounts,DC=Traini
changetype: modify
replace: c
c: PK
Hi Sharath,
If you are not interested in above method of modifying user information then use following batch script.
This batch will automatically create .ldf file with required format and then will import using LDIFDE utility.
Read batch instructions before you execute.
:: ===============
:: READ THIS FIRST
:: ===============
::
:: * This script require "UserInfo.txt" file on C: drive root from where it will pick NT Logins.
:: * UserInfo.txt file should be in following format (semi-colon separated)
:: Syntax:
: NTLoginID;Street;State;Zip
:: Like:
:: FKAZI;Clifton Block-2;Sindh;75600;PK
::
:: * Successful run will generate "ModifyInfoReport.txt" file on C: drive root.
:: * Copy and paste following script in notepad and save it with any name having .cmd extension.
::
:: *** SCRIPT START ***
@Echo Off
SETLOCAL EnableDelayedExpansion
IF NOT EXIST C:\UserInfo.txt Goto ShowErr
FOR %%R IN (C:\UserInfo.txt) Do IF %%~zR EQU 0 Goto ShowErr
IF EXIST C:\Input.ldf DEL /F /Q C:\Input.ldf
FOR /F "delims=; tokens=1-5" %%a IN (C:\UserInfo.txt) Do (
REM Echo %%a - %%b - %%c - %%d - %%e
DSQuery user -samid "%%a*" >C:\UsrTmp.txt
SET /p u=<C:\UsrTmp.txt
SET UserID=!u:~1!
SET UserID=!UserID:~-0,-1!
Echo Processing !UserID!
Echo Dn: !UserID!>>C:\Input.ldf
Echo changetype: modify>>C:\Input.ldf
Echo replace: streetAddress>>C:\Input.ld
Echo streetAddress: %%b>>C:\Input.ldf
Echo ->>C:\Input.ldf
Echo.>>C:\Input.ldf
Echo Dn: !UserID!>>C:\Input.ldf
Echo changetype: modify>>C:\Input.ldf
Echo replace: St>>C:\Input.ldf
Echo St: %%c>>C:\Input.ldf
Echo ->>C:\Input.ldf
Echo.>>C:\Input.ldf
Echo Dn: !UserID!>>C:\Input.ldf
Echo changetype: modify>>C:\Input.ldf
Echo replace: postalCode>>C:\Input.ldf
Echo postalCode: %%d>>C:\Input.ldf
Echo ->>C:\Input.ldf
Echo.>>C:\Input.ldf
Echo Dn: !UserID!>>C:\Input.ldf
Echo changetype: modify>>C:\Input.ldf
Echo replace: c>>C:\Input.ldf
Echo c: %%e>>C:\Input.ldf
Echo ->>C:\Input.ldf
Echo.>>C:\Input.ldf
)
IF EXIST C:\Input.ldf LDIFDE -I -K -F C:\Input.ldf >ModifyInfoReport.txt
Goto EndScript
:ShowErr
Echo "C:\UserInfo.txt" file does not exist or file is empty!
:EndScript
IF EXIST C:\UsrTmp.txt DEL /F /Q C:\UsrTmp.txt
ENDLOCAL
:: *** SCRIPT END ***
This is the content in ModifyInfoReport.txt
Connecting to "in-ads-srv02.Development.
Logging in as current user using SSPI
Importing directory from file "C:\Input.ldf"
Loading entriesAdd error on line 1: Invalid DN Syntax
The server side error is "The object name has bad syntax."
0 entries modified successfully.
An error has occurred in the program
No log files were written. In order to generate a log file, please
specify the log file path via the -j option.
.
Sorry my mistake had a % in the file.
Now i get this.
Connecting to "in-ads-srv02.Development.
Logging in as current user using SSPI
Importing directory from file "C:\Input.ldf"
Loading entries3 entries modified successfully.
The command has completed successfully
.....
Can you please add the city also.Forgot to mention
Street,city,State,Zipcode,
If any 1 is not mentioned what happens.Will it be an error.
Userinfo.txt > Sharathr;No 17;t-nagar;600088;India
input.ldf >
Dn: CN=Sharath Reddy,OU=Named Accounts,OU=User Accounts,OU=IND,OU=Countri
changetype: modify
replace: streetAddress
streetAddress: No 17
-
Dn: CN=Sharath Reddy,OU=Named Accounts,OU=User Accounts,OU=IND,OU=Countri
changetype: modify
replace: St
St: t-nagar
-
Dn: CN=Sharath Reddy,OU=Named Accounts,OU=User Accounts,OU=IND,OU=Countri
changetype: modify
replace: postalCode
postalCode: 600088
-
Dn: CN=Sharath Reddy,OU=Named Accounts,OU=User Accounts,OU=IND,OU=Countri
changetype: modify
replace: c
c: India
-
The data is in this format.
Is there any chance to update data in this format.
This would help me to reduce man hrs to update this manually....
Address :G R Plaza,714
City : Chennai
State : TN
Zip Code : 600 006
Country : India
Title : Quality Engineer
Company : Kini R&D Pvt. Ltd.
Department : ima
Office : GR plaza Second Floor
Phone : 3981 8981 /Ext :8809
Sorry for the trouble.
Input should be in following format
NTLoginID;Street;City;Stat
^-------------------------
:: ===============
:: READ THIS FIRST
:: ===============
::
:: * This script require "UserInfo.txt" file on C: drive root from where it will pick NT Logins.
:: * UserInfo.txt file should be in following format (semi-colon separated)
:: Syntax:
:: NTLoginID;Street;City;Stat
:: Like:
:: FKAZI;Clifton Block-2;Karachi;Sindh;7560
::
:: * Successful run will generate "ModifyInfoReport.txt" file on C: drive root.
:: * Copy and paste following script in notepad and save it with any name having .cmd extension.
::
:: *** SCRIPT START ***
@Echo Off
SETLOCAL EnableDelayedExpansion
IF NOT EXIST C:\UserInfo.txt Goto ShowErr
FOR %%R IN (C:\UserInfo.txt) Do IF %%~zR EQU 0 Goto ShowErr
IF EXIST C:\Input.ldf DEL /F /Q C:\Input.ldf
FOR /F "delims=; tokens=1-6" %%a IN (C:\UserInfo.txt) Do (
REM Echo %%a - %%b - %%c - %%d - %%e
DSQuery user -samid "%%a*" >C:\UsrTmp.txt
SET /p u=<C:\UsrTmp.txt
SET UserID=!u:~1!
SET UserID=!UserID:~-0,-1!
Echo Processing !UserID!
Echo Dn: !UserID!>>C:\Input.ldf
Echo changetype: modify>>C:\Input.ldf
Echo replace: streetAddress>>C:\Input.ld
Echo streetAddress: %%b>>C:\Input.ldf
Echo ->>C:\Input.ldf
Echo.>>C:\Input.ldf
Echo Dn: !UserID!>>C:\Input.ldf
Echo changetype: modify>>C:\Input.ldf
Echo replace: l>>C:\Input.ldf
Echo l: %%c>>C:\Input.ldf
Echo ->>C:\Input.ldf
Echo.>>C:\Input.ldf
Echo Dn: !UserID!>>C:\Input.ldf
Echo changetype: modify>>C:\Input.ldf
Echo replace: St>>C:\Input.ldf
Echo St: %%d>>C:\Input.ldf
Echo ->>C:\Input.ldf
Echo.>>C:\Input.ldf
Echo Dn: !UserID!>>C:\Input.ldf
Echo changetype: modify>>C:\Input.ldf
Echo replace: postalCode>>C:\Input.ldf
Echo postalCode: %%e>>C:\Input.ldf
Echo ->>C:\Input.ldf
Echo.>>C:\Input.ldf
Echo Dn: !UserID!>>C:\Input.ldf
Echo changetype: modify>>C:\Input.ldf
Echo replace: c>>C:\Input.ldf
Echo c: %%f>>C:\Input.ldf
Echo ->>C:\Input.ldf
Echo.>>C:\Input.ldf
)
IF EXIST C:\Input.ldf LDIFDE -I -K -F C:\Input.ldf >ModifyInfoReport.txt
Goto EndScript
:ShowErr
Echo "C:\UserInfo.txt" file does not exist or file is empty!
:EndScript
IF EXIST C:\UsrTmp.txt DEL /F /Q C:\UsrTmp.txt
ENDLOCAL
:: *** SCRIPT END ***
India = IN
For complete list visit.
http://www.iana.org/root-w
or
http://ftp.ics.uci.edu/pub
:: ===============
:: READ THIS FIRST
:: ===============
::
:: * This script require "UserInfo.txt" file on C: drive root from where it will pick NT Logins.
:: * UserInfo.txt file should be in following format (semi-colon separated)
:: Syntax:
:: NTLoginID;Street;City;Stat
:: Like:
:: FKAZI;Clifton Block-2;Karachi;Sindh;7560
::
:: * Successful run will generate "ModifyInfoReport.txt" file on C: drive root.
:: * Copy and paste following script in notepad and save it with any name having .cmd extension.
::
:: *** SCRIPT START ***
@Echo Off
SETLOCAL EnableDelayedExpansion
IF NOT EXIST C:\UserInfo.txt Goto ShowErr
FOR %%R IN (C:\UserInfo.txt) Do IF %%~zR EQU 0 Goto ShowErr
IF EXIST C:\Input.ldf DEL /F /Q C:\Input.ldf
FOR /F "delims=; tokens=1-10" %%a IN (C:\UserInfo.txt) Do (
DSQuery user -samid "%%a*" >C:\UsrTmp.txt
SET /p u=<C:\UsrTmp.txt
SET UserID=!u:~1!
SET UserID=!UserID:~-0,-1!
Echo Processing !UserID!
Echo Dn: !UserID!>>C:\Input.ldf
Echo changetype: modify>>C:\Input.ldf
Echo replace: streetAddress>>C:\Input.ld
Echo streetAddress: %%b>>C:\Input.ldf
Echo ->>C:\Input.ldf
Echo.>>C:\Input.ldf
Echo Dn: !UserID!>>C:\Input.ldf
Echo changetype: modify>>C:\Input.ldf
Echo replace: l>>C:\Input.ldf
Echo l: %%c>>C:\Input.ldf
Echo ->>C:\Input.ldf
Echo.>>C:\Input.ldf
Echo Dn: !UserID!>>C:\Input.ldf
Echo changetype: modify>>C:\Input.ldf
Echo replace: St>>C:\Input.ldf
Echo St: %%d>>C:\Input.ldf
Echo ->>C:\Input.ldf
Echo.>>C:\Input.ldf
Echo Dn: !UserID!>>C:\Input.ldf
Echo changetype: modify>>C:\Input.ldf
Echo replace: postalCode>>C:\Input.ldf
Echo postalCode: %%e>>C:\Input.ldf
Echo ->>C:\Input.ldf
Echo.>>C:\Input.ldf
Echo Dn: !UserID!>>C:\Input.ldf
Echo changetype: modify>>C:\Input.ldf
Echo replace: c>>C:\Input.ldf
Echo c: %%f>>C:\Input.ldf
Echo ->>C:\Input.ldf
Echo.>>C:\Input.ldf
Echo Dn: !UserID!>>C:\Input.ldf
Echo changetype: modify>>C:\Input.ldf
Echo replace: title>>C:\Input.ldf
Echo title: %%g>>C:\Input.ldf
Echo ->>C:\Input.ldf
Echo.>>C:\Input.ldf
Echo Dn: !UserID!>>C:\Input.ldf
Echo changetype: modify>>C:\Input.ldf
Echo replace: department>>C:\Input.ldf
Echo department: %%h>>C:\Input.ldf
Echo ->>C:\Input.ldf
Echo.>>C:\Input.ldf
Echo Dn: !UserID!>>C:\Input.ldf
Echo changetype: modify>>C:\Input.ldf
Echo replace: physicalDeliveryOfficeName
Echo physicalDeliveryOfficeName
Echo ->>C:\Input.ldf
Echo.>>C:\Input.ldf
Echo Dn: !UserID!>>C:\Input.ldf
Echo changetype: modify>>C:\Input.ldf
Echo replace: telephoneNumber>>C:\Input.
Echo telephoneNumber: %%j>>C:\Input.ldf
Echo ->>C:\Input.ldf
Echo.>>C:\Input.ldf
)
IF EXIST C:\Input.ldf LDIFDE -I -K -F C:\Input.ldf >ModifyInfoReport.txt
Goto EndScript
:ShowErr
Echo "C:\UserInfo.txt" file does not exist or file is empty!
:EndScript
IF EXIST C:\UsrTmp.txt DEL /F /Q C:\UsrTmp.txt
ENDLOCAL
:: *** SCRIPT END ***
Business Accounts
Answer for Membership
by: mwoolmanPosted on 2007-06-20 at 11:12:57ID: 19326879
Well The easy way would be to select all of the users that the change needs to be made to from within AD Users and Computers. Right click and go to Properties. From there you can select and apply changes the bulk user objects. If you have to script it you should be able to use "dsmod user" to change those attributes. I'm not sure what switch(s) you will have to use though.