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?
Windows Server 2003NetworkingNetwork Management

Avatar of undefined
Last Comment
Henrik Johansson

8/22/2022 - Mon
Brian Pierce

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
...
ASKER
lenivan

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.
Henrik Johansson

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

Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes
ASKER CERTIFIED SOLUTION
Henrik Johansson

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question