Hey Hobbs13 - Thanks a ton for this. Based on your script, I changed mine. Sometimes, though, I change the password for a remote user and they cannot change an expired password remotely. I wanted to use your script for office workers, but I didn't want two different scripts and two different links on the LS page.
So I did this:
If WScript.Arguments.Count = 1 Then
struser= WScript.Arguments(0)
Set objUser = GetObject("LDAP://" & struser)
strCN = objUser.Get("cn")
chgmsg = MsgBox("Do you want to Force " & strCN & " to" & VbCrLf & _
" Change his/her Password at Next Logon?" & VbCrLf & VbCrLf & _
"'Yes' will set a default password and require a change at next logon." & VbCrLf & _
VbTab & "- Use 'Yes' for users in the office." & VbCrLf & VbCrLf & _
"'No' will ask you to set the password; it will not require it to be changed." & VbCrLf & _
VbTab & "- Use 'No' for remote users as they cannot change an " & VbCrLf & _
VbTab & " expired password remotely." & VbCrLf & VbCrLf & _
"'Cancel' will cancel the operation." _
, 547, "Force " & strCN & " to Change Password At Next Logon?")
If chgmsg = 6 Then
objUser.SetPassword("Change1now")
objUser.pwdLastSet = 0
objUser.SetInfo
msgbox "Password changed to: Change1now" & VbCrLf & VbCrLf & _
" - It Must Be Changed At Next Logon!",,strCN & "'s password has been changed!"
end if
If chgmsg = 7 Then
password1=InputBox("Enter " & strCN & "'s new password:",strCN)
password2=InputBox("Confirm " & strCN & "'s new password:",strCN)
if password1 <> "" then
if password1=password2 then
objUser.SetPassword(password1)
msgbox strCN & "'s password has been changed to: " & password1,,strCN & "'s password has been changed!"
else
msgbox "The passwords do not match",,"Error, try again"
end if
else
msgbox "The password cannot be blank",,"Error, try again"
end if
end if
end if
Basically, it asks if I want to force a password change at the next logon. If Yes, then it'll automatically set the default password and force the user to change it. If No, then it'll ask for the password (twice) and it will not force a change.
It works great for me. I hope other's find it useful.
Jono