King Computer Solutions
spacer
07.11.2010

Script to reset all active directory users passwords in an organizational unit OU

This will replace all the users passwords in UserOU with Newpassword!

Update the italicised items to suit you domain

Option Explicit
Dim objOU, objUser
Dim strPassword
Dim intCounter, intAccValue, intPwdValue
‘————————
strPassword = “Newpassword!”
intAccValue = 544
intCounter = 0
set objOU =GetObject(“LDAP://OU=UserOU,OU=MyCompanyOU,C=MyDomain,DC=LOCAL“)
For each objUser in objOU
If objUser.class=”user” then
objUser.SetPassword strPassword
objUser.SetInfo
objUser.Put “userAccountControl”, intAccValue
objUser.SetInfo
intCounter = intCounter +1
End if
next
WScript.Echo strPassword & ” is Password. UserAccountValue = ” _
& intAccValue & vbCr & intCounter & ” accounts changed”
WScript.Quit