Jump to content

Recommended Posts

Posted

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

Posted (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 by FN-Greatermanchester
Posted

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.

Posted

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

Posted

@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

  • Thanks 1
Posted
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)
Posted
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

  • 4 months later...
Posted
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...?
Posted

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

Posted (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 by BJG

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 account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...