Sponsored Links

Login Form






Lost Password?

Syndicate

Home
Set the Local Admin Password Across Your Domain PDF Print E-mail
User Rating: / 2
PoorBest 
Written by Cheyenne Harden   
The company I work for has a lot of computers and all of them had different local Admin passwords.
I created this script to set all local admin passwords! All you need to do is enter the names of your hosts into a .txt file.Then drop the .txt file onto the script. 

----------COPY EVERYTHING BELOW THIS LINE for the Script----------
'Change local admin passwords - just drop a txt file with a list of computers name onto the script
' Created by Chey Harden on 12.3.07


On Error Resume Next

Const HKLM = &H80000002
Const ForReading = 1
strPass = "YOUR PASSWORD HERE"
strKeyPath = "Software"
strKeyBluWav = "Software\BluWav"
BluWavExists = 0
strValueName = "AdminPassword"
strValue2 = 1
strChangePass = 0

Set objArgs = WScript.Arguments
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile(objArgs(0), ForReading)
 strComputers = objFile.ReadAll
 objFile.Close
 arrComputers = Split(strComputers, vbCrLf)
 
 For Each strComputer In arrComputers
  Set objShell = CreateObject("Wscript.Shell")
  Set objScriptExec = objShell.Exec("ping -n 2 -w 1000 " & strComputer)
  Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\default:StdRegProv")
  oReg.EnumKey HKLM, strKeyPath, arrSubKeys
   If InStr(objScriptExec.StdOut.ReadAll, "Reply") > 0 Then 
    Err.Clear
    Set objUser = GetObject("WinNT://" & strComputer & "/Administrator, user")
   
    If Err.Number Then
         WScript.Echo strComputer & ": Incorrect Username"
    Err.Clear
    Else
     FindKey()
     'WScript.Echo BluWavExists
     CreateKey()
     ReadRegString()
     If strChangePass = 1 Then
      objUser.SetPassword strPass
      objUser.SetInfo
      strChangePass = 0
     Else
      'WScript.Echo "Password Already Set!"
     End If
     'WScript.Echo " " & strComputer & " - Password successfully changed"
    End If 
   Else
   WScript.Echo strComputer & " : Could not find host!"   
   End If
 Next

 

Function FindKey()
 For Each subkey In arrSubKeys
  'WScript.Echo subkey ' For Trouble shooting
  If subkey = "BluWav" Then
   BluWavExists = 1
  End If
 Next
End Function

 

Function CreateKey()
 If BluWavExists = 0 Then
  oReg.CreateKey HKLM,strKeyBluWav
 End If 
End Function

 

Function ReadRegString()
 oReg.GetStringValue HKLM,strKeyBluWav,strValueName,strValue
 'WScript.Echo strValue
  If strValue = 1 Then
   'WScript.Echo "Key Written"
  Else
   WriteRegString()
  End If 
End Function

 

Function WriteRegString()
 oReg.SetStringValue HKLM,strKeyBluWav,strValueName,strValue2
 strChangePass = 1
End Function  

----------COPY EVERYTHING ABOVE THIS LINE for the Script----------

 

 

PLEASE MAKE SURE NO WORD WRAPPING IS HAPPENING IN YOUR SCRIPT!!!

1. Create a .txt file with a list of the computers.
2. Make sure to be an admin on the target machines.
3. Change this line to reflect your password: strPass = "YOUR PASSWORD HERE"
4. Drag and drop the .txt file onto the script.

 


This information is provided "AS IS" with no warranties expressed or implied.

Comments
Add NewSearch
LazyNetworkAdmin - Nice     | 75.45.85.xxx | 15-12-2007 21:04:09
I am glad you made this. I was just about to scrounge up my old script that did this using CUSERMGR.exe

I like this one much better.
razvan - ...or...   | 193.222.63.xxx | 18-04-2008 10:16:07
Create a file called Pwdchange.vbs

In this file put the command:

Set WshShell = WScript.CreateObject("WScript.Shell"
wshShell.Run "Net User administrator thepassword"

Save the file
Download the screnc.exe file from Microsoft
Encrypt the file using screnc.
This will change the file from a .vbs to a .vbe It will not be readable by any users, but will run fine.

...and use it with GPO. [Computer Configuration\Windows Settings\Scripts\Startup]
Chey Harden - Good to know Razvan     | 70.235.104.xxx | 23-04-2008 11:45:06
This is a great idea, but I didn't want to run this as a GPO! I created this to run on demand for client sites. But thanks for the information as it is appreciated!

Chey Harden
Network Engineer
Write comment
Name:
Email:
 
Website:
Title:
UBBCode:
[b] [i] [u] [url] [quote] [code] [img] 
 
 
 
Security Image
Please input the anti-spam code that you can read in the image.

Copyright (C) 2007 Alain Georgette / Copyright (C) 2006 Frantisek Hliva. All rights reserved.

 
Tag it:
Delicious
Furl it!
Spurl
digg
YahooMyWeb
< Prev   Next >
 

Google Search

Google