Link to home
Start Free TrialLog in
Avatar of lenivan
lenivan

asked on

Force shutdown through GPO?

I am looking for a way to force a computer shutdown every friday evening in our office. I would like to manage this centrally through GPO or something on the server side. I do not want to have to install software on each individual machine as I have 200 of them.

What is the best end easily centrally managed way of going about this?
Avatar of Brian Pierce
Brian Pierce
Flag of United Kingdom of Great Britain and Northern Ireland image

You can create a batch file to use the shutdown command, this ca be scheduled on one machine eg the DC and will shutdown the others at the scheduled time

example
shutdown -s -t 10 -f -m \\Computer01
shutdown -s -t 10 -f -m \\Computer02
shutdown -s -t 10 -f -m \\Computer03
...
Avatar of lenivan
lenivan

ASKER

According to your example, I would have to create a new line for every computer on my network? I don't think I want to do that. I want to have the flexibility to change shutdown times and computers as needed without going into individual command lines.

Is there a piece of software that can manage shutdowns form the server side? I'm looking for a simple managed approach.
You can do it with some scripting to push it out to all computers in a specific OU
The sample script below will create or change the task to schedule shutdown 19:00 (7PM) every friday for all computers in a given OU.

createshutdown.cmd CREATE "OU=Computer OU-path,DC=domain,DC=com"

To centralize it with GPO, you can create a custom ADM and use it in a GPO.
Create another scheduled task running a script that pull the shutdown time from the GPO.
@echo off
IF "%~2"=="" goto _help
IF "%1"=="CREATE" goto _run
IF "%1"=="CHANGE" goto _run
goto _help
 
:_run
SET RUNUSER=administrator
SET RUNPASS=
ECHO %1
for /F %%a in ('dsquery computer %2^|dsget computer -samid^| find /v "dsget"^|find /v "samid"') do (
  for /F "delims=$" %%b in ("%%a") do (
    echo. %%b
 
    schtasks /%1 /S %%b /RU %RUNUSER% /RP %RUNPASS% /TN shutdownFriday /SC WEEKLY /ST 19:00 /D FRI /F /TR shutdown
  )
)
 
goto _eof
 
:_help
echo. Syntax
echo.   %0 CREATE "OU=oupath,DC=dc,DC=com" - Create task for all computers in OU
echo.   %0 CHANGE "OU=oupath,DC=dc,DC=com" - Change task for all computers in OU
echo.
 
:_eof
SET RUNUSER=
SET RUNPASS=

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Henrik Johansson
Henrik Johansson
Flag of Sweden image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial