How To Change Remote Computer Local Account Password Using Powershell

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. 
  1. $adminPassword = "Password here"  
  2. $adminUser = [ADSI] "WinNT://$computerName/Administrator"  
  3. $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.
  1. $computer = "C:\users\radhakrishnan.govindan\hosts.txt"  
  2. foreach($computerName in $computer) {  
  3.     $adminPassword = "Password here"  
  4.     $adminUser = [ADSI]  
  5.     "WinNT://$computerName/Administrator"  
  6.     $adminUser.SetPassword($adminPassword)  
  7. }  
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.
Ebook Download
View all
Learn
View all