FN-GM Posted June 21, 2008 Posted June 21, 2008 hi I am looking a script that will shutdown a small selection of computers. I would prefer it if the script looked at a text file to define the computers rather having the computer names in the script. Does anyone have one please? Z
SYNACK Posted June 21, 2008 Posted June 21, 2008 (edited) Try this one does it by text file or OU and logs any errors: Redmond | Column: Shut Down, Already Edited June 21, 2008 by SYNACK
Lesley_tech Posted June 21, 2008 Posted June 21, 2008 Run -> CMD -> shutdown -i -> Browse -> find computers -> Add note -> shutdown Hope this helps
FN-GM Posted June 21, 2008 Author Posted June 21, 2008 (edited) Run -> CMD -> shutdown -i -> Browse -> find computers -> Add note -> shutdown Hope this helps I use that utility allot but its not quite what i am after. Try this one does it by text file or OU and logs any errors: Redmond | Column: Shut Down, Already Would i just list the computers in the .txt one on each line? also for shutting them down would i use /action:poweroff Edited June 21, 2008 by FN-Greatermanchester
SYNACK Posted June 21, 2008 Posted June 21, 2008 Would i just list the computers in the .txt one on each line? also for shutting them down would i use /action:poweroff Yes sounds right, haven't actually used it before but the standard method is a pc name on each line and you would want to use the command switch above to make them fully shutdown.
SYNACK Posted June 21, 2008 Posted June 21, 2008 Here is is as a code listing, you will need to copy it and paste it into a text file called shutdownrestart.wsf Best Practice 97 - Shutdown Shutdownrestart.wsf
imiddleton25 Posted June 22, 2008 Posted June 22, 2008 we use psshutdown its one of the best tools we have found see below PsShutdown from sysinternals (Now part of Microsoft) download from PsShutdown Initiate a shutdown/reboot of a local or remote computer, logoff a user, lock a system. Syntax psshutdown [[\\computer[,computer[,..] | @file [-u user [-p passwd]]] -s|-r|-h|-d|-k|-a|-l|-o [-f] [-c] [-t nn|h:m] [-n s] [-v nn] [-e [u|p]:xx:yy] [-m "message"] Options: computer The computer on which the user account resides. Default=local system a wildcard (\\*), will affect all computers in the current domain. -p passwd Specify a password for user (optional). Passed as clear text. If omitted, you will be prompted to enter a hidden password. -u user Specify a user name for login to remote computer(optional). @file Execute the command on each of the computers listed in the file. -a Abort a shutdown (only possible while a countdown is in progress) -c Allow the shutdown to be aborted by the interactive user -d Suspend the computer -e [u|p]:xx:yy Shutdown reason code, 'u' = user, 'p'= planned shutdown. xx is the major reason code (must be less than 256) yy is the minor reason code (must be less than 65536) -f Force all running applications to exit during the shutdown instead of giving them a chance to gracefully save their data. -h Hibernate the computer -k Poweroff the computer (reboot if poweroff is not supported) -l Lock the computer -m "message" Specify a message to logged-on users when a shutdown countdown commences -n Timeout in seconds connecting to remote computers -o Logoff the console user -r Reboot after shutdown -s Shutdown without poweroff -t Countdown in seconds until the shutdown (default: 20 seconds) or the time of shutdown (in 24 hour notation) -v Display message for the specified number of seconds before the shutdown. default= display a shutdown notification dialog, specifying a value of 0 results in no dialog. - Help, display the supported options. This tool allows administrators to create a batch file that will run against multiple computers to perform a mass change of the administrator password. Examples: Reboot \\workstation64 as part of an OS upgrade psshutdown \\workstation64 -r -e p:2:3 Related Commands: SHUTDOWN - With full list of reason codes Equivalent Linux BASH command: shutdown - Shutdown or restart linux
RabbieBurns Posted June 22, 2008 Posted June 22, 2008 @echo off cls echo Shutting Down Computers... if not exist computers.txt goto NOTFOUND FOR /F %%i in (computers.txt) do shutdown -s -m \\%%i goto END :NOTFOUND echo computers.txt not found GOTO END :END echo Done... just put all the computer names in computer.txt 1
mattx Posted June 22, 2008 Posted June 22, 2008 I miss GOTO commands..... I hated having to port some of my older batch type stuff into loops...... Still, thats life.
powdarrmonkey Posted June 23, 2008 Posted June 23, 2008 @Zak: PM me, I have a home-made tool I'd like you to beta if that's ok.
SpuffMonkey Posted June 23, 2008 Posted June 23, 2008 Could someone post a script to shutdown PCs using psshutdown? It keeps hanging when I try it - I try to give a warning, then shutdown and log it all to a log file (2003 & XP)
mattx Posted June 23, 2008 Posted June 23, 2008 Could someone post a script to shutdown PCs using psshutdown? It keeps hanging when I try it - I try to give a warning, then shutdown and log it all to a log file (2003 & XP) This is what the Admin Bar does: psshutdown -c -k @shutdownpcs.txt -f -t 30
SpuffMonkey Posted June 24, 2008 Posted June 24, 2008 This is what the Admin Bar does: psshutdown -c -k @shutdownpcs.txt -f -t 30 Thanks - I'll give it a try.
BJG Posted November 17, 2008 Posted November 17, 2008 I've recently started using psshutdown to switch off groups of computers at the end of the day. But I'd prefer not to shut down any computers that are logged in. Methinks a bit of scripting with psloggedon will be necessary. Anyone set things up like this...?
CyberNerd Posted November 17, 2008 Posted November 17, 2008 Some kind edugeeker wrote this batch file: at | find "shutdown.exe" > c:\atlist.txt for /F "tokens=1" %%a in (c:\atlist.txt) do at %%a /delete at 23:15 /every:m,t,w,th,f,s,su %SystemRoot%\system32\shutdown.exe -s -t 0 -f I call it as a startup script from GPO to ensure computers are shutdown at 23:15
powdarrmonkey Posted November 17, 2008 Posted November 17, 2008 Shutdownertron, whilst it isn't user-aware, does allow a user to override it so that they can carry on uninterrupted, and has a variable delay on it.
BJG Posted November 17, 2008 Posted November 17, 2008 (edited) Thanks for the replies. Does that script avoid computers that are logged in, while shutting down ones that are logged out...? If so, how does it work...? Edited November 17, 2008 by BJG
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now