Jump to content

Change admin password on all computers on a server


Recommended Posts

Hi guys, my department controls about over 500 computers on a server, most comps are xp, some are NT and windows 2003. to access these comps we use remote computer and each computer has a specific name. the problem is that right now all the admin passwords are overdue and many ppl from other departments know it, is there a way for autoit to automatically go into all these computers and change the admin password? and if so, where should i look in the helpfile, also if there are any similar examples that would be helpful as well!

Link to comment
Share on other sites

http://www.keroonsoftware.com/go/resetpro.htm $150 dollar

#include <Array.au3>

Local $avArray[10]

$avArray[0] = "Computer01"
$avArray[1] = "Computer02"
$avArray[2] = "Computer03"
$avArray[3] = "Computer04"
$avArray[4] = "Computer05"
$avArray[5] = "Computer06"
$avArray[6] = "Computer07"
$avArray[7] = "Computer08"
$avArray[8] = "Computer09"
$avArray[9] = "Computer10"

For $i = 0 To 9
    Msgbox (0, "Computername", $avArray[$i])
Next

Replace the msgbox command with the correct commandline to change password from a remote computer where $avArray[$i] is the computername

Good luck

If your computer names are stored in to a text document you could also use _FileReadToArray instead of creating the array yourself.. see help because

$avArray[0] will be the number of computers so the for statement will begin with 1 instead of 0

Edited by Emiel Wieldraaijer

Best regards,Emiel Wieldraaijer

Link to comment
Share on other sites

I ran into the same problem, we support a bunch of departments and I needed a way to have a different password for each. I came up with something that can handle multiple depts with different passwords using arrays (with some help from WeaponX) and ran it using SMS. It works on XP but never tested on Server or NT. This is adapted from my script but I think it will work anyway. You could probably run it by GPO as a startup or shutdown script or add a runasset and put in a domain admin account and put it in the regular logon script.

AutoItSetOption("MustDeclareVars", 1)
Dim $objWshShell, $objFSO, $objNetwork, $objWMI
Dim $arrDeptCodes, $i, $Admin
Dim $objItem, $objUser, $DeptPwords


$objFSO = ObjCreate("Scripting.FileSystemObject")
$objWMI = ObjGet("winmgmts:" & "{impersonationLevel=impersonate}!\\.\root\cimv2")

;Gets the Local Admin Account Name like the Function says.
$Admin = GetAdministratorName(@ComputerName)

$DeptPwords = "Password1"

;Sets up the COM for changing the password
$objUser = ObjGet("WinNT://./" & $Admin)
If @error Then
    Exit
    ; Aborts the process with a failure code.
Else
    $objUser.SetPassword($DeptPwords)
    $objUser.SetInfo()

    If @error Then
        Exit
        ; Aborts the process with a failure code, I hope.
    EndIf
EndIf

;Get the local administrator account Name, Hope it works because this blows up if it don't.
Func GetAdministratorName($ComputerName)
    Dim $UserSID, $oWshNetwork, $oUserAccounts, $objWMIService
    $objWMIService = ObjGet("winmgmts:{impersonationLevel=impersonate}!//" & $ComputerName & "/root/cimv2")
    $oUserAccounts = $objWMIService.ExecQuery("Select Name, SID from Win32_UserAccount WHERE Domain = '" & $ComputerName & "'")
    For $oUserAccount In $oUserAccounts
        If StringLeft($oUserAccount.SID, 9) = "S-1-5-21-"  And _
                StringRight($oUserAccount.SID, 4) = "-500"  Then
            Return $oUserAccount.Name
        EndIf
    Next
EndFunc   ;==>GetAdministratorName

Exit
Link to comment
Share on other sites

I ran into the same problem, we support a bunch of departments and I needed a way to have a different password for each. I came up with something that can handle multiple depts with different passwords using arrays (with some help from WeaponX) and ran it using SMS. It works on XP but never tested on Server or NT. This is adapted from my script but I think it will work anyway. You could probably run it by GPO as a startup or shutdown script or add a runasset and put in a domain admin account and put it in the regular logon script.

AutoItSetOption("MustDeclareVars", 1)
Dim $objWshShell, $objFSO, $objNetwork, $objWMI
Dim $arrDeptCodes, $i, $Admin
Dim $objItem, $objUser, $DeptPwords


$objFSO = ObjCreate("Scripting.FileSystemObject")
$objWMI = ObjGet("winmgmts:" & "{impersonationLevel=impersonate}!\\.\root\cimv2")

;Gets the Local Admin Account Name like the Function says.
$Admin = GetAdministratorName(@ComputerName)

$DeptPwords = "Password1"

;Sets up the COM for changing the password
$objUser = ObjGet("WinNT://./" & $Admin)
If @error Then
    Exit
    ; Aborts the process with a failure code.
Else
    $objUser.SetPassword($DeptPwords)
    $objUser.SetInfo()

    If @error Then
        Exit
        ; Aborts the process with a failure code, I hope.
    EndIf
EndIf

;Get the local administrator account Name, Hope it works because this blows up if it don't.
Func GetAdministratorName($ComputerName)
    Dim $UserSID, $oWshNetwork, $oUserAccounts, $objWMIService
    $objWMIService = ObjGet("winmgmts:{impersonationLevel=impersonate}!//" & $ComputerName & "/root/cimv2")
    $oUserAccounts = $objWMIService.ExecQuery("Select Name, SID from Win32_UserAccount WHERE Domain = '" & $ComputerName & "'")
    For $oUserAccount In $oUserAccounts
        If StringLeft($oUserAccount.SID, 9) = "S-1-5-21-"  And _
                StringRight($oUserAccount.SID, 4) = "-500"  Then
            Return $oUserAccount.Name
        EndIf
    Next
EndFunc   ;==>GetAdministratorName

Exit
Thanks, I will try to get a lab going and test it out, if I have questions can I ask you?
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...