Re: Remotely Reset the local administrator password
- From: "Randy" <randy.steinberg@xxxxxxxxx>
- Date: 22 Dec 2006 10:54:57 -0800
This should do the trick. Just change the path to where you want the
log, the domain info, and the new password. It can take a while to
complete. I ran it against the 1500 in my domain, and it took almost 2
hours.
-----------------------------------------------------------
Set FSO = CreateObject("Scripting.FileSystemObject")
Set WshNetwork = WScript.CreateObject("WScript.Network")
Set TextFile = FSO.OpenTextFile("C:\scripts\AutoChangePW.log", 2, True)
On Error Resume Next
Const ADS_SCOPE_SUBTREE = 2
Set objConnection = CreateObject("ADODB.Connection")
Set objCommand = CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
Set objCommand.ActiveConnection = objConnection
objCommand.Properties("Page Size") = 1000
objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE
objCommand.CommandText = _
"SELECT Name FROM 'LDAP://dc=scripting,dc=microsoft,dc=com' WHERE
objectCategory='computer'"
Set objRecordSet = objCommand.Execute
' Get new password
newPassword="PassWord"
' Open the log file
Set oOutFile = oFSO.OpenTextFile(outFilename, ForAppending, True)
Do Until objRecordSet.EOF
strComputer = objRecordSet.Fields("Name").Value
Set objUser = GetObject("WinNT://" & strComputer & "/administrator,
user")
If Err.Number <> 0 Then
oOutFile.writeline Now & vbTab & "Error connecting to " & strComputer
& " --- " & Err.Description
Err.Clear
ErrorOccurred = True
Else
' Set the password for the account
objUser.SetPassword newPassword
objUser.SetInfo
If Err.Number <> 0 Then
oOutFile.writeline Now & vbTab & "Error setting password for " &
strComputer & _
"\pcadmin" & " --- " & Err.Description
Err.Clear
ErrorOccurred = True
Else
oOutFile.writeline (Now & vbTab & "Password set for " & strComputer
& "\administrator")
End If
End If
objRecordSet.MoveNext
Loop
' Clean up the environment
oOutFile.writeline (Now & vbTab & "Ending script...")
oInFile.close
oOutFile.close
If ErrorOccurred Then
msgbox "Script completed with errors. Please check the log file."
Else
MsgBox "Script completed successfully."
End If
Set TextFile = Nothing
Set WshNetwork = Nothing
Set FSO = Nothing
.
- Follow-Ups:
- Re: Remotely Reset the local administrator password
- From: MPerrault
- Re: Remotely Reset the local administrator password
- References:
- Remotely Reset the local administrator password
- From: Shrikant
- Remotely Reset the local administrator password
- Prev by Date: Re: Installing a Enterprise Root CA in a mixed mode environment
- Next by Date: Re: Questions regarding replication connections
- Previous by thread: Remotely Reset the local administrator password
- Next by thread: Re: Remotely Reset the local administrator password
- Index(es):
Loading