Importing User changes to AD

  • Thread starter Thread starter gurvinder.nijjar
  • Start date Start date
G

gurvinder.nijjar

We need to change all our users properties in AD such as the path to their
home directories and profile needs to be changed to a different server name.
We have over 500 users and doing this for each user will take a very long
time. Is there a way of automating this such that it can be done in one go.
Like exporting all users properties and then making the change and then
importing it back to AD. I know you have ldidfe and csvde. But does this
and will it cause any problems when you importing back such a lose any
settings. Is there any other way of doing this.
 
We need to change all our users properties in AD such as the path to their
home directories and profile needs to be changed to a different server name.
We have over 500 users and doing this for each user will take a very long
time. Is there a way of automating this such that it can be done in one go.
Like exporting all users properties and then making the change and then
importing it back to AD. I know you have ldidfe and csvde. But does this
and will it cause any problems when you importing back such a lose any
settings. Is there any other way of doing this.
Use dsquery and dsmod from the Active Directory Command-Line tools, tip 6820 in
the 'Tips & Tricks' at http://www.jsiinc.com

See tip 7714.

Rerplace \\OldSrv and \\NewSrv in the following .bat file:

@echo off
setlocal
set oldsrv=\\OldSrv
set newsrv=\\NewSrv
set qry1=dsquery * domainroot -filter
set qry2= "(&(objectCategory=Person)(objectClass=User))"
set qry3= -attr distinguishedName homeDirectory profilePath -L -limit 0
set qry=%qry1%%qry2%%qry3%
set OK=N
for /f "Tokens=1*" %%a in ('%qry%') do (
set attr=%%a
set value=%%b
call :test1
)
endlocal
goto :EOF
:err
@echo Logic - User:%user%
goto :EOF
:test1
if /i "%attr%" EQU "distinguishedName:" set user=%value%&goto :EOF
if /i "%attr%" EQU "homeDirectory:" set home=%value%&goto :EOF
if /i "%attr%" NEQ "profilePath:" goto err
set prof=%value%
set OK=N
set newhome=%home%
set newprof=%prof%
if "%home%" NEQ "" call set newhome=%%home:%oldsrv%=%newsrv%%%
if "%prof%" NEQ "" call set newprof=%%prof:%oldsrv%=%newsrv%%%
if "%home%" NEQ "%newhome%" set OK=Y
if "%prof%" NEQ "%newprof%" set OK=Y
if "%OK%" EQU "N" goto :EOF
dsmod user "%user%" -hmdir "%newhome%" -profile "%newprof%"


Jerold Schulman
Windows: General MVP
JSI, Inc.
http://www.jsiinc.com
 
Back
Top