I have a script that is supposed to force the user to change their password at the next logon. Unfortunately is isn't working. Here's what i have.
In the user account in AD, under the Account tab. The User cannot change password, and password never expires boxes are checked. When i manually uncheck those the script works.
Is there a way to uncheck those two boxes with this script? thanks.
Code:
' PwdLastSet .vbs
' Sample VBScript to force a user to change password at next logon
' Author Guy Thomas [URL unfurl="true"]http://computerperformance.co.uk/[/URL]
' Version 1.1 - May 2005
' --------------------------------------------------------------'
Option Explicit
Dim objOU, objUser, objRootDSE
Dim strContainer, strDNSDomain
Dim intCounter, intPwdValue
' Bind to Active Directory Domain
Set objRootDSE = GetObject("LDAP://RootDSE")
strDNSDomain = objRootDSE.Get("DefaultNamingContext")
' -------------------------------------------------------------'
' Important change OU= to reflect your domain
' -------------------------------------------------------------'
strContainer = "OU=Password_Test_OU, "
strContainer = strContainer & strDNSDomain
intCounter = 0
' Here we force a change of password at next logon
intPwdValue = 0
' Loop through OU=, resetting all user accounts
set objOU =GetObject("LDAP://" & strContainer )
For each objUser in objOU
If objUser.class="user" Then
objUser.SetPassword "password"
objUser.Put "PwdLastSet",intPwdValue
objUser.SetInfo
End If
intCounter = intCounter +1
Next
' Optional section to record how many accounts have been set
WScript.Echo "PwdLastSet = " & intPwdValue _
& vbCr & "Accounts changed = " & intCounter
WScript.Quit
' End of Sample PwdLastSet VBScript
Is there a way to uncheck those two boxes with this script? thanks.