anyone ever used psshutdown before?

metallicafan

[H]ard|DCer of the Month - May 2010
Joined
Mar 30, 2005
Messages
2,205
Hello all-

I was looking to shutdown a bunch of computers at work every night with a simple batch script and the Sysinternals utility psshutdown.

Here is the basic script I am starting with:

Code:
echo Starting shutdown at:
time /T

psshutdown -c -m "Nightly Shutdown" -n 5 @c:\shutdownlist.txt /accepteula
 
echo Shutdown Complete.
echo Shutdown finished at:
time /T

pause

It works fine but the only thing thats weird is that at the end of the psshutdown command it just hangs. It never makes it to the echo Shutdown Complete line. I thought maybe it was just the computer I was working on but I have tried several different computers with the same result.

Now if I hit control-C when its done cycling thorugh all the computers (when it is just hanging) it will prompt: Do you want to cancel this job(Y/N). If I hit N then it completes the echo statements right away.

Does anyone have any suggestions to why this might be happening?
 
I use it to reboot certain computers every night. My batch file is really generic.

cd C:\PSTools

psshutdown.exe @computers.txt -f -r


And that's it. Works every night.
 
Try adding a -f (force) to the list.

You might want to put a -s in there as well. Not sure if it needs it, but it might work a little better with it.

Why are you using -n? It looks to me that thats the timeout before it disconnects from the remote computer. Are you trying to make it so the machine reboots in 5 seconds? If so, try the -t parameter.


You might want to look into setting up a scheduled task on each machine and letting it run each night, then you could just use the shutdown command thats ships with Windows.
 
I use a scheduled task on one machine to reboot all the computers that I want to reboot at night. That way I can add or subtract machines from a central location and not have to connect to each one.
 
I use a scheduled task on one machine to reboot all the computers that I want to reboot at night. That way I can add or subtract machines from a central location and not have to connect to each one.

Bingo. To my knowledge (unless i missed something) there is no way to make the built in shutdown.exe to execute on several computers at once. So i figured I'd just use psshutdown. Now I should mention that the script is workng exactly the way I want it, but when all the computers have been sent the command to shutdown it just hangs and the script never timestamps at the end. All the computers are shutting down properly. Plus as Burnout mentioned with psshutdown there is only one place to have to run a scheduled task and you can easily modify which computers get shutdown.


Why are you using -n? It looks to me that thats the timeout before it disconnects from the remote computer. Are you trying to make it so the machine reboots in 5 seconds? If so, try the -t parameter.
Look at the parameter descriptions again. This is the timeout time. Some of these computers might not be turned on when the shutdown script is run. The -n is so that if it cant connect to the machine in 5 seconds it moves on to the next machine on the list. Otherwise if several of the computers are already turned off the script takes forever to run.

Does anyone else have a good way to do this on a Windows domain? Can it be done with a GPO? Maybe I'll just have to write a script in Perl or something.:)
 
here's my script for rebooting citrix servers...

change logon /disable
msg * /time:180 You have 3 minutes to save your work and logoff before the server restarts.
sleep 180
rem net stop cpsvc
rem net stop spooler
del /q %systemroot%\system32\spool\printers\*.*
del /q %systemroot%\system32\spool\drivers\w32x86\3\*.tmp
del /q /f %systemroot%\temp\*.*
delprof /q /i
sleep 10
change logon /enable
sleep 2
psshutdown -r -f -e p:4:1
 
Back
Top