star_topology
In Runtime
- Messages
- 195
Hello,
I'm trying to refine a script I got from computerperformance.co.uk in regards to resetting passwords on an OU in Active Directory. I would like to drill down to the sub OU in my domain that I have specified. For explanation purposes, I have an OU, "High School" and four sub-OUs "Freshmen" "Sophomores" etc. The script only resets passwords that are in the main OU "High School." Any help would be appreciated.
--------------------------
' pw_reset.vbs
Option Explicit
Dim objOU, objUser, objRootDSE
Dim strContainer, strDNSDomain, strPassword
Dim intCounter, intAccValue, intPwdValue, intpwdLastSet
strContainer = "OU=High School,"
strPassword = "l33tsauce*"
intAccValue = 544
intPwdValue = 0
intCounter = 0
intpwdLastSet = 0
' -------------------------------------------------------'
' Makes the user change l33tsauce* password at first logon
' intpwdLastSet = 0 sets "Password Must be Changed at next Logon"
' -------------------------------------------------------'
Set objRootDSE = GetObject("LDAP://RootDSE")
strDNSDomain = objRootDSE.Get("DefaultNamingContext")
strContainer = strContainer & strDNSDomain
set objOU = GetObject("LDAP://" & strContainer )
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 the password. UserAccountValue = " _
& intAccValue & vbCr & intCounter & " accounts changed"
WScript.Quit
--------------------------
I'm trying to refine a script I got from computerperformance.co.uk in regards to resetting passwords on an OU in Active Directory. I would like to drill down to the sub OU in my domain that I have specified. For explanation purposes, I have an OU, "High School" and four sub-OUs "Freshmen" "Sophomores" etc. The script only resets passwords that are in the main OU "High School." Any help would be appreciated.
--------------------------
' pw_reset.vbs
Option Explicit
Dim objOU, objUser, objRootDSE
Dim strContainer, strDNSDomain, strPassword
Dim intCounter, intAccValue, intPwdValue, intpwdLastSet
strContainer = "OU=High School,"
strPassword = "l33tsauce*"
intAccValue = 544
intPwdValue = 0
intCounter = 0
intpwdLastSet = 0
' -------------------------------------------------------'
' Makes the user change l33tsauce* password at first logon
' intpwdLastSet = 0 sets "Password Must be Changed at next Logon"
' -------------------------------------------------------'
Set objRootDSE = GetObject("LDAP://RootDSE")
strDNSDomain = objRootDSE.Get("DefaultNamingContext")
strContainer = strContainer & strDNSDomain
set objOU = GetObject("LDAP://" & strContainer )
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 the password. UserAccountValue = " _
& intAccValue & vbCr & intCounter & " accounts changed"
WScript.Quit
--------------------------