In this tutorial, I will walk you through how to schedule computers to automatically shut down using Group Policy.
In fact, there is no native functionality in Windows to shut down computers, but we will use Group Policy to deploy a scheduled task to Active Directory domain member computers that will shut them down.
Often not lazy, users do not shut down their computers in the evening, which poses “two problems”:
- Security, if the computers are not turned off, it means that some updates are not applied
- Still related to security, some of the “viruses” run in the evening when there is less activity.
- The second reason, the carbon footprint, it reduces electricity consumption.
Creating Group Policy to Shut Down Computers
From a domain controller, create a group policy on the OU that contains the computers you want to shut down, right-click and click Create a GPO in this domain, and link it here 1.
Name the Group Policy 1 and click the OK button 2 to create the object.
Edit the group policy, which has just been created, right-click on it and click on Edit 1.
Go to the following location: Computer Configuration / Preferences / Control Panel Settings / Scheduled Tasks.
In the central area, right click and click go to New 1 and click on Scheduled task (at least Windows 7) 2.
On the General tab, name the task 1 and indicate the user NT AUTHORITY\SYSTEM 2.
We will now configure the triggers of the scheduled task, i.e. when it runs, go to the Triggers tab 1 and click on the New button 2.
Select At the scheduled time 1, choose Daily 2 and configure the execution time 3 (here 8:00 p.m.) and click on OK 4 to create the trigger.
The trigger is added 1.
Now, we are going to add our action, i.e. shutting down the computer. Go to the Actions 1 tab and click on New 2.
Action, choose Start a program 1, in the Program/script field, enter the path to the shutdown.exe executable: C:\Windows\System32\shutdown.exe 2, specify the following parameters : -s -t 0 -f 3 to configure computer shutdown and click OK4 to create the action.
The action is added 1, click Apply 2 and OK 3 to create the scheduled task.
The scheduled task is added 1.
Our scheduled task is almost ready, we need to configure the task to run with the user not logged in and the highest privileges.
Open the task by double clicking on it, as can be seen in the screenshot below, the user has been changed.
Specify the NT AUTHORITY\SYSTEM user 1 again, select Run even if the user is not logged on 2 then check the Run with highest privileges 3 box. Apply 4 then the parameters and click on OK 5.
Group Policy is ready.
Check group policy on a computer
From a computer where group policy applies, if it is already on, use the gpupdate /force command to update the GPOs and restart the computer.
After restarting, log in to it then the task scheduler, you must open the task scheduler as an administrator, otherwise you will only see the scheduled tasks of the logged-in user.
As we can see on the capture below, the scheduled task has been added and the computer will be automatically shut down every day at 8:00 p.m.
Through this tutorial, you have seen how to create a group policy to create a scheduled task and how to program the automatic shutdown of computers.
This solution effectively allows the automatic shutdown of computers at a scheduled time, but poses a problem, it is not possible to stop the task and if for some reason x or y a user is still working on the computer. will be turned off.
For a more flexible solution in the event that you want to set up management of automatic computer shutdowns, I advise you to use FOG which allows you to program automatic computer shutdowns, with the advantage of warning the user and leave the possibility of canceling the stop.