It’s easier to schedule a production server reboot for after hours than it is to come in early or stay late.
These instructions will take you through scheduling a reboot for a Windows machine. You don’t need a script for this, just some basic knowledge of Windows’ task scheduler (which seems to get worse with each new Windows edition…). The instructions were written using Windows Server 2012.
RDP to the Machine in Question
You can login as any administrative user.
Open Task Scheduler
Located in Administrative Tools. You can also search for task scheduler on the Start page.
Create a Basic Task
Expand the Task Scheduler Library and right-click to create a basic task. The screenshot below shows the task I already created.
The same option is available in the Action menu.
Name the Task. Add the Description as Necessary
Set the Trigger
Select One Time to schedule the reboot for a specific date and time.
Set Your Desired Date and Time
Set the Program and Arguments
In the Program/script field, type just Powershell.exe
In the Add arguments field, type restart-computer -force
Note the important space between restart-server and -force.
Confirm and Finish
Ensure the Task Runs When You’re Gone
Once you click Finish, the Create Basic Task Wizard window will close. Right-click your new task and select properties. Open the tasks’s General tab and then select Run whether user is logged on or not. Click OK.
You will be asked to enter credentials. Use credentials that will have the authority to restart the server. Be careful about using the Administrator credentials, or those of a staff member, which could change.