Change local admin password

M

Miha

Hi

Is it possible and how to change local admin password on all Win2000/WinXP
computer in domain?
Can't find any function in GPO, the only way that I can think of is via
script, but it's a problem that script is run with users privileges, and
they are ordinary users not admins?
Any ideas?
Regards,
Miha
 
M

Mathieu CHATEAU

Hello,

Here is a vbscript from the famous Brian Desmond.
Fill a workstations.txt with workstations names and the newPass = ""
If you don't know how to fill the text file, please let me know.
If you administrator local name is not "Administrator", change it in the
script (line WinNT://" & line & "/Administrator, user")


'==========================================================================
' NAME: Change local administrator password on list of machines
' AUTHOR: Brian Desmond
' DATE : 6/19/2006
'==========================================================================
Option Explicit

' What to change the password to
Const newPass = ""

Const LogFile = "AdminReset.log"
Const inputFile = "workstations.txt"

Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")

Dim shl
Set shl = WScript.CreateObject("WScript.Shell")

Dim fil
Set fil = fso.OpenTextFile(inputFile)

WriteToLog "Beginning Pass of " & inputFile & " at " & Now()
WScript.Echo "Beginning Pass of " & inputFile & " at " & Now()
'On Error Resume Next

Dim usr
Dim line
Dim exec
Dim pingResults
While Not fil.AtEndOfStream
line = fil.ReadLine

Set exec = shl.Exec("ping -n 2 -w 1000 " & line)
pingResults = LCase(exec.StdOut.ReadAll)

If InStr(pingResults, "reply from") Then
WriteToLog line & " responded to ping"
WScript.Echo line & " responded to ping"

On Error Resume Next

Set usr = GetObject("WinNT://" & line & "/Administrator, user")
usr.SetPassword newPass
usr.SetInfo

If Err.Number <> 0 Then
WriteToLog "Error resetting password on " & line & ": " & Err.Description
WScript.Echo "Error resetting password on " & line & ": " &
Err.Description
Err.Clear
Else
WriteToLog "Password Reset on " & line
WScript.Echo "Password Reset on " & line
End If
Else
WriteToLog line & " did not respond to ping"
WScript.Echo line & " did not respond to ping"
End If
Wend

fil.Close

Sub WriteToLog(LogData)
On Error Resume Next

Dim fil
'8 = ForAppending
Set fil = fso.OpenTextFile(LogFile, 8, True)

fil.WriteLine(LogData)

fil.Close
Set fil = Nothing
End Sub

Set usr = Nothing
Set fil = Nothing
Set fso = Nothing
Set shl = Nothing
 
M

Miha

Thank you. Works like a charm!
Regards,Miha


Mathieu CHATEAU said:
Hello,

Here is a vbscript from the famous Brian Desmond.
Fill a workstations.txt with workstations names and the newPass = ""
If you don't know how to fill the text file, please let me know.
If you administrator local name is not "Administrator", change it in the
script (line WinNT://" & line & "/Administrator, user")


'==========================================================================
' NAME: Change local administrator password on list of machines
' AUTHOR: Brian Desmond
' DATE : 6/19/2006
'==========================================================================
Option Explicit

' What to change the password to
Const newPass = ""

Const LogFile = "AdminReset.log"
Const inputFile = "workstations.txt"

Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")

Dim shl
Set shl = WScript.CreateObject("WScript.Shell")

Dim fil
Set fil = fso.OpenTextFile(inputFile)

WriteToLog "Beginning Pass of " & inputFile & " at " & Now()
WScript.Echo "Beginning Pass of " & inputFile & " at " & Now()
'On Error Resume Next

Dim usr
Dim line
Dim exec
Dim pingResults
While Not fil.AtEndOfStream
line = fil.ReadLine

Set exec = shl.Exec("ping -n 2 -w 1000 " & line)
pingResults = LCase(exec.StdOut.ReadAll)

If InStr(pingResults, "reply from") Then
WriteToLog line & " responded to ping"
WScript.Echo line & " responded to ping"

On Error Resume Next

Set usr = GetObject("WinNT://" & line & "/Administrator, user")
usr.SetPassword newPass
usr.SetInfo

If Err.Number <> 0 Then
WriteToLog "Error resetting password on " & line & ": " &
Err.Description
WScript.Echo "Error resetting password on " & line & ": " &
Err.Description
Err.Clear
Else
WriteToLog "Password Reset on " & line
WScript.Echo "Password Reset on " & line
End If
Else
WriteToLog line & " did not respond to ping"
WScript.Echo line & " did not respond to ping"
End If
Wend

fil.Close

Sub WriteToLog(LogData)
On Error Resume Next

Dim fil
'8 = ForAppending
Set fil = fso.OpenTextFile(LogFile, 8, True)

fil.WriteLine(LogData)

fil.Close
Set fil = Nothing
End Sub

Set usr = Nothing
Set fil = Nothing
Set fso = Nothing
Set shl = Nothing



--
Cordialement,
Mathieu CHATEAU
English blog: http://lordoftheping.blogspot.com
French blog: http://www.lotp.fr
 
G

Guest

you can use RUNAS command and execute the script as domain admin.
Of course, you need to hide the domain admin password.
(usually, you should create a temporary domain admin account on AD and use
it.)
 
G

Guest

Could you please explain how to fill the workstations.txt file and structure?

Thanks, Mike
 
M

Miha

Mike, you just type your computers in a plain text file like in each line
(without any commas)

IT-MIKE
IT-JOHN
IT-JON
.....

Regards,Miha
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top