- notageek.it di Mirko Iodice - http://www.notageek.it -
Change Local Administrator Password On All Computers In A List
Posted By Mirko On 13 giugno 2007 @ 12:15 In Scripts | 4 Comments
Questo script permette di resettare/cambiare la password dell’account "Administrator" locale di tutti i computer specificati in un elenco.
Richiede in input soltanto un semplice file di testo (computers.txt) contenente i nomi (o gli indirizzi IP) dei PC sui quali effettuare il reset della password di "Administrator"; è possibile generare velocemente tale elenco utilizzando lo script “List All Computers And Users Within An OU And SubOUs [2]“.
Come output vengono generati due files: "errors.txt" e "changepwd.txt". Il primo riporta gli errori di connessione e grazie al loro numero/descrizione sarà possibile distinguere i computer spenti o inesistenti da quelli che hanno negato l'accesso alle vostre credenziali utente, il secondo invece costituisce il risultato dell'esecuzione ed ha appunto lo scopo di mettere in evidenza i client sui quali invece il cambio password è avvenuto con successo.
Gestisce in maniera completamente autonoma le operazioni di scrittura dei risultati su file di testo, potete perciò eseguirlo indifferentemente con entrambi i motori WSH ("wscript.exe" oppure "cscript.exe") senza quindi dovervi preoccupare di reindirizzarne manualmente l'output.
La password che verrà impostata impostata è l'unica informazione da modificare nel codice sorgente, la trovate a riga 17: objAdmin.SetPassword "P@ssw0rd".
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | Set oFS = CreateObject("Scripting.FileSystemObject") Set oTS = oFS.OpenTextFile("computers.txt") Set oTSOut = oFS.CreateTextFile("errors.txt") Set ResultsFile = oFS.CreateTextFile("changedpwd.txt") TotErr = 0 'go through the text file Do Until oTS.AtEndOfStream 'get next computer strComputer = oTS.ReadLine On Error Resume Next Set objAdmin = GetObject("WinNT://" & strComputer & "/Administrator,user") If Err <> 0 Then TotErr = TotErr + 1 oTSOut.WriteLine "Error on " & strComputer & ":" & Err.Number & ", " & Err.Description Else objAdmin.SetPassword "P@ssw0rd" objAdmin.SetInfo If Err <> 0 Then TotErr = TotErr + 1 oTSOut.WriteLine "Error on " & strComputer & ":" & Err.Number & ", " & Err.Description Else ResultsFile.WriteLine("Administrator password changed on " & strComputer) End If End If Loop oTS.Close oTSOut.Close ResultsFile.Close If TotErr = 0 Then msgbox "Task completed with " & TotErr & " errors" Else msgbox "Task completed with " & TotErr & " errors" & Chr(10) & Chr(13) & "Please check the error log" End If |
Article printed from notageek.it di Mirko Iodice: http://www.notageek.it
URL to article: http://www.notageek.it/change-local-administrator-password-on-all-computers-in-a-list.html
URLs in this post:
[1] una guida: http://www.notageek.it/wsh-change-local-admin-passwords-cambiare-password-admin-locale.html
[2] List All Computers And Users Within An OU And SubOUs: http://www.notageek.it/list-all-computers-and-users-within-an-ou-and-subous.html
[3] change_local_administrator_password_on_all_computers_in_a_list.zip: http://www.notageek.it/wp-includes/files/change_local_administrator_password_on_all_computers_in_a_list.zip
Click here to print.
Copyright © 2009 notageek.it. All rights reserved.