How to Change remote computer Local account password using Powershell

Being Administrators, we will come across the situation where we need to reset the passwords for all the Servers and Workstations Local  administrator Accounts. we can not go to each machine and reset the passwords.
In this article, we will see how to reset the Local administrator password.
Below command will help in reseting the password for a single machine.
  1. $adminPassword = “Password here”  
  2. $adminUser = [ADSI] “WinNT://$computerName/Administrator”  
  3. $adminUser.SetPassword($adminPassword)  
Now we will elevate it to set for bulk computers. Using the below commands by parsing the bulk computers in the text file as input.
  1. $computer = “C:\users\radhakrishnan.govindan\hosts.txt”  
  2. foreach($computerName in $computer)  
  3. {  
  4. $adminPassword = “Password here”  
  5. $adminUser = [ADSI] “WinNT://$computerName/Administrator”  
  6. $adminUser.SetPassword($adminPassword)  
  7. }  

Here, we are using the WMI filter which is faster and easy way to reset even for Windows Server 2003 and latest Windows machines.

Author Bio

Radhakrishnan Govindan

Leave a Reply

Your email address will not be published. Required fields are marked *