How do I script the unlocking of domain user accounts?
To use this script you will need to enter the relevant username and domain into message boxes that prompt.
UserName = InputBox(”Enter the user’s login name that you want to unlock:”)
If UserName = “” Then
WScript.Echo “No username was given or you clicked Cancel”
WScript.Quit(1)
End If
DomainName = InputBox(”Enter the domain name in which the user account exists:”)
If DomainName = “” Then
WScript.Echo “No domain was given or you clicked Cancel”
WScript.Quit(1)
End If
Set UserObj = GetObject(”WinNT://”& DomainName &”/”& UserName &”")
If UserObj.IsAccountLocked = -1 then UserObj.IsAccountLocked = 0
UserObj.SetInfo
If err.number = 0 Then
Wscript.Echo “The Account Unlock Failed. Check that the account is, ” & _
“in fact, locked-out.”
Else
Wscript.Echo “The Account Unlock was Successful”
End If
Account Unlock Active Directory domain account locked vbscriptAccount Unlock Active Directory domain account locked vbscript
Filed under: vbscript, Active Directory


Leave a Reply