here's a sample-batch that should help you get
started
/Guido
set inputfile=%1
if '%inputfile%'=='' goto ErrInput
if '%inputfile%'=='' goto ErrInput
set logfile=.\%inputfile%_log.txt
echo.
echo Updating password settings for user listed in: %inputfile%
echo Logfile: %logfile%
echo.
echo Updating password settings for user listed in: %inputfile%
echo Logfile: %logfile%
echo.
echo.
>> %logfile%
echo ---------------------------------------- >> %logfile%
echo Inputfile: %inputfile% >> %logfile%
date /T >> %logfile%
time /T >> %logfile%
echo Step 1: setting PW to new value >> %logfile%
echo ---------------------------------------- >> %logfile%
echo. >> %logfile%
echo ---------------------------------------- >> %logfile%
echo Inputfile: %inputfile% >> %logfile%
date /T >> %logfile%
time /T >> %logfile%
echo Step 1: setting PW to new value >> %logfile%
echo ---------------------------------------- >> %logfile%
echo. >> %logfile%
REM Read users from inputfile and execute UpdatePWsetting routine
set /A count=1
FOR /F "tokens=1-2 delims=;" %%i in (%inputfile%) DO set CurUser=%%i & set newPW=%%j & call :Sub_PWchange
start notepad %logfile%
goto
END
:Sub_PWchange
echo now updating User%count%: %CurUser% PW:%newPW%
echo User%count%: %CurUser% PW:%newPW% >> %logfile%
dsquery user -samid %curUser%|dsmod user -pwd %newPW% >> %logfile%
REM *** dsmod user -pwd only works on Win2k3 DCs => for Win2k "net user" cmd be used ***
REM net user %CurUser% %newPW% >> %logfile%
set /A count=%count%+1
GOTO :EOF
echo now updating User%count%: %CurUser% PW:%newPW%
echo User%count%: %CurUser% PW:%newPW% >> %logfile%
dsquery user -samid %curUser%|dsmod user -pwd %newPW% >> %logfile%
REM *** dsmod user -pwd only works on Win2k3 DCs => for Win2k "net user" cmd be used ***
REM net user %CurUser% %newPW% >> %logfile%
set /A count=%count%+1
GOTO :EOF
:ErrInput
echo.
echo **********************************************
echo ERROR: missing inputfile - script will quit
echo.
echo Syntax: update_pwChange.bat myUser-list.csv
echo Format of input-file: username;newPW
echo **********************************************
echo.
pause
echo.
echo **********************************************
echo ERROR: missing inputfile - script will quit
echo.
echo Syntax: update_pwChange.bat myUser-list.csv
echo Format of input-file: username;newPW
echo **********************************************
echo.
pause
:END
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Douglas M. Long
Sent: Montag, 24. Mai 2004 15:49
To: [EMAIL PROTECTED]
Subject: RE: [ActiveDir] Password set and enable account
Oh
yeah, I guess I have to read the username from a file and pass it into the dsmod
command also. Do I just want a list of users in a .txt file, .cvs??? And how do
I read from that?
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]On Behalf Of Douglas M. Long
Sent: Monday, May 24, 2004 9:41 AM
To: [EMAIL PROTECTED]
Subject: [ActiveDir] Password set and enable accountOk, so my task is to generate random passwords and enable the accounts for 3200 users. The user accounts and all attributes were first created with ldife, and I am now thinking about using the dsmod utility to do accomplish the password set and account enablement. I wish I knew vbs like you guys do, but I dont yet (this years resolution). So here is what I have for the password generation part:Function Password_GenPass( nNoChars, sValidChars )
' nNoChars = length of generated password
' sValidChars = valid characters. If zerolength-string ( "" )then
' default is used: A-Z AND a-z AND 0-9Const szDefault = "abcdefghijklmnopqrstuvxyzABCDEFGHIJKLMNOPQRSTUVXYZ0123456789"
Dim nCount
Dim sRet
Dim nNumber
Dim nLengthRandomize 'init randomIf sValidChars = "" Then
sValidChars = szDefault
End If
nLength = Len( sValidChars )For nCount = 1 To nNoChars
nNumber = Int((nLength * Rnd) + 1)
sRet = sRet & Mid( sValidChars, nNumber, 1 )
Next
Password_GenPass = sRet
End FunctionWScript.Echo "Your password: " & Password_GenPass( 10, "" )What is my next move? I am guessing I have to pass this password to a variable, instead of echo, and then somehow pass that into the dsmod command, but as I already said, I dont know vb script. Any help is highly appreciated.