Being Administrators, we come across a situation where we need to reset the passwords for all the Servers and Workstations' Local Administrator Accounts. It is not feasible to go to each machine and reset the passwords.
In this write-up, we will see how to reset the local administrator password.
The below command helps in reseting the password for a single machine.
- $adminPassword = "Password here"
- $adminUser = [ADSI] "WinNT://$computerName/Administrator"
- $adminUser.SetPassword($adminPassword)
Now, we will elevate it to set for bulk computers. We are using the below commands by parsing the bulk computers in the text file as input.
- $computer = "C:\users\radhakrishnan.govindan\hosts.txt"
- foreach($computerName in $computer) {
- $adminPassword = "Password here"
- $adminUser = [ADSI]
- "WinNT://$computerName/Administrator"
- $adminUser.SetPassword($adminPassword)
- }
Here, we are using the WMI filter which is faster and an easy way to reset password even for Windows Server 2003 and latest Windows machines.