Force automatic restart even with users logged in after installation of updates on Windows 8.1 Professional
Solution 1:
Updated version of Drifter104s answer.
This will do what you want with a Powershell script, as it still seems very hard (impossible?) to get this configured correctly through group policy / registry.
-
Install the Test-PendingReboot Powershell module:
Install-Module -Name PendingReboot
-
Then create a scheduled task to run the following powershell commands
$RebootStatus = $null $RebootStatus = Test-PendingReboot | Select IsRebootPending | Where-Object {$_.IsRebootPending -like "True"} if ($RebootStatus -ne $null) {shutdown -r -f -t 60}
The changes I made compared to the previous answer are:
- The Powershell script provided previously is no longer being developed and has been replaced with the one I linked.
- Installing the script as a PowerShell module should automatically make it available for all users, meaning that you don't need to make it load automatically (the link to those instructions is now broken any way)
- The results from the new PS Module are slightly different and so the query to find out 'RebootStatus' needed changing.
- I also initialised 'RebootStatus' to
$null
to avoid false positives in case the second line of the script is broken, commented out, wrapped in a conditional etc.
Solution 2:
This will do what you want with a powershell script.
download the powershell function/module from here https://gallery.technet.microsoft.com/scriptcenter/Get-PendingReboot-Query-bdb79542
Then edit the powershell profile for all users so that function gets loaded automatically. This link explains how to do that http://www.gsx.com/blog/bid/81096/Enhance-your-PowerShell-experience-by-automatically-loading-scripts
Then create a scheduled task to run the following powershell commands
$RebootStatus = "NotSet"
$RebootStatus = Get-PendingReboot | Select WindowsUpdate | Where-Object {$_.WindowsUpdate -like "True"}
if ($RebootStatus -ne $null) {shutdown -r -f -t 60}
Basically if the return value is false it sets $RebootStatus to empty, otherwise it populates it with a value. It checks that and reboots if $RebootStatus has any value other then $null.
Sorry if this goes over things you already know.