Change Local Administrator Password On All Computers In A List
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“.
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 |
Contenuti correlati
- WSH – Modificare o Creare variabili d’ambiente sui PC Client di una rete
- Come cambiare/resettare la password degli amministratori locali di un dominio Windows – How to reset local administrator passwords in a Windows Domain
- List Clients Local Admininistrators
- Change or Create Environmental Variables On All Computers In A List
- Add Up To Three Domain Groups To Local Admins

This work, unless otherwise expressly stated, is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License.
Print This • Email this • Twit This! • Add to del.icio.us • Share on Facebook • Digg This! • Stumble It! • AddThis! • Share on Segnalo Alice • Share on OKNotizie

2 marzo 2010 alle 13:07
grazie x il tuo script
4 marzo 2010 alle 21:57
@ Luca
Prego :-)