Pages

Sunday, October 13, 2013

Reset Password for Local Administrator account on multiple computers Remotely.

Here is a simple batch script which can be used to Reset Password for Local Administrator account on multiple computers Remotely.
This script uses pspasswd.exe utility which can be found in sysinternals tools.

Step 1:- Create a notepad file and copy the below lines of code (shown in blue italics) to it and save it as ChangePWD.cmd

@echo off
for /f "tokens=1,2* delims=," %%h in (servers.csv) do (
pspasswd \\%%h %%i %%j>>output.txt ||echo !!ERROR!! The server name %%h  is not reachable or ID %%i is not found >>output.txt
)
cls
echo.
echo.
echo.
echo Script has completed..
Pause >nul

Step 2:- Now open excel and put ServerNames in column A, the user ID in Column B & new Passwords in Column C and save it as Servers.CSV. when opened in notepad it will look something like this. Don't put anything on the first row.

Server1,administrator,5IH881jd
Server2,administrator,IH3g1jda
Server3,administrator,asdfsa3

Step 3:-Download pspasswd.exe from http://live.sysinternals.com (direct link http://live.sysinternals.com/pspasswd.exe)

Step 4:- keep all three files ( ChangePWD.cmd, Servers.csv & pspasswd.exe) in one folder.

Now execute the ChangePWD.cmd file and it will start resetting passwords on all servers listed in servers.csv and will write the result in a new text file called output.txt.


Please post for any query/feedback/suggestions on this.

No comments:

Post a Comment