I was at a customer and we recently set up a new DNS Server. I asked him to ensure that all servers pointed to the new server. 140 remote servers – estimated 6 days of work to do this manually.
Ever had this experience and just need to get the job done ASAP? PSExec is a saviour in these cases.
Simply download PSTools from http://technet.microsoft.com/en-gb/sysinternals/bb896649.aspx
PSExec is in here, all thanks to Mark Russinovich. Although PSTools contains a load of tools, I really want to focus on PSExec right now. This is the one tool I use more than any.
In summary, whatever you can run in the CMD prompt or script, you can do remotely with PSExec.
E.g. Get every machine in the domain to renew it’s IP Address:
psexec \\* ipconfig /renew
It’s that simple.
Ok, to get all Domain Controllers to restart their netlogon service:
for /F %i in (‘dsquery server -o rdn’) do psexec \\%i net stop netlogon & net start netlogon
Ok, change the Primary DNS Server on all Domain Controllers:
for /F %i in (‘dsquery server -o rdn’) do psexec \\%i netsh interface ipv4 set dnsservers static 192.168.0.1 primary
Perhaps you have a specific list of computers to run a command on. Add them to a text file (like computers.txt). Then place the text file in the directory you are running PSExec from and run the following:
PSExec @filename.txt CommandToRun (e.g. shutdown /r)
One issue I found which is really a pain is when having to use PSExec and run a command which interfaces with remote network resources. e.g.
psexec \\server15 \\server\share\executable.exe
This won’t work unless you supply credentials. Something like this:
psexec -u domain\user -p PasswordHere\\server15 \\server\share\executible.exe