This repository is for all of the code involved with setting up a scheduled update and reboot for windows servers.
- Save a copy of
MainTask.ps1into your File Explorer. - Make sure your execution policy allows you to run PowerShell scripts from the PowerShell command line.
- Check your policy by running
Get-ExecutionPolicyin PowerShell. - I suggest the policy to be set to
RemoteSigned. To change your execution policy, run PowerShell in administrator mode and runSet-ExecutionPolicy -ExecutionPolicy RemoteSigned. Then respond to the prompt withYorA.
- Check your policy by running
- Open Task Scheduler.
- Right Click
Task Scheduler Libraryand clickCreate Basic Task. - Give your task a meaningful name, such as "Update and Restart". Add a description if you desire.
- Click
Nextand select how often you want your script to run. In this example, I'm choosingMonthly. - Click
Next. If you choseDaily,Weekly,Monthly, orOne time, select the day and time you want your script to start.- Since I chose to run my task monthly, I'll also need to select
<Select all months>to run every month. - Select a day(s) of the month to run the script. I'll just choose the first of the month.
- Since I chose to run my task monthly, I'll also need to select
- Click
Nextand selectStart a program. - Click
Next. ForProgram/script, select the powershell executables. This should be located inC:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe. In this case, you can just copy and paste this directory into the input box. - On the same page, go to
Add arguments (optional)and add the full path to your copy of the MainTask.ps1 script. - Click
Next. Review your info and clickFinish. - In the top box in the middle pane, scroll down and select your created task. Right click on it and select 'properties'.
- Under
Security options, check the box toRun with highest privileges. ClickOKwhen done.