Changing Admin password on Windows systems using Powershell.

Summary:

Was looking for the method to do this, it’s pretty simple, but everyone had very detailed posts of other things they were doing (checks and balances).  Here is the key snippet to do it:

   1: #This simply gets you the object to work with.  You can replace 
   2: #'nameofcomputer' with a variable to target more systems.
   3: $admin = [adsi]("WinNT://" + nameofcomputer + "/administrator, user")
   4:  
   5: #This invokes the set password method and changed the administrator password
   6: #to Whatever1
   7: $admin.psbase.invoke("SetPassword", "Whatever1")

If you want more robust script that records data of it’s changes see here.

No comments: