MicrosoftDocs / Windows-Admin-Center-Ideas-and-Feedback

Windows Admin Center's hub for ideas and feedback.
Creative Commons Attribution 4.0 International
20 stars 9 forks source link

WAC Scheduled reboot for Windows Updates installation not working #295

Open ale32lfo opened 3 months ago

ale32lfo commented 3 months ago

Gateway Version: 1.5.2403.08001 Extension Version msft.sme.windows-update, version 4.9.2

To Reproduce

Using Windows Admin Center to install windows updates on any server of our organization, picking the option to reboot the server to finalize the updates at a given time, the server will ignore my settings and will always reboot immediatly after patch installation.

After some digging, I think I know where the problem resides: The PS module named Microsoft.SME.WindowsUpdate defines the function "Install-WACWUWindowsUpdates" with a parameter for $restartTime. When using WAC GUI, the javascript takes the $restartTime from the form and generates a script using the function stated before, with the restartTime value in en-US regional date format. Problem is, our servers are using Italian Regional format data because they're located in Italy. Thus, the date difference fails and so the server reboots immediately.

Setting a scheduled reboot time, the restart time will be represented in a variable using this format: $restartTime = 'Thu Mar 28 2024 19:49:50+0100'; The function later uses $restartTime in order to calculate a $waitTime for shutdown.exe: $waitTime = [decimal]::round(((Get-Date $restartTime) - (Get-Date)).TotalSeconds); This difference between date items is failing because the output of the command "Get-Date" in our servers is localized in Italian: giovedì 28 marzo 2024 17:21:38 This means that the scheduled reboot feature can't work for all servers where regional format data is not the same as the "en-US" standard.

Expected behavior Scheduled restart to finalize Windows Updates should work as intended. One possible way to fix this could be to normalize the dates prior to determine the waitTime desidered for the reboot (shutdown /r /t) command:

$currdate = Get-Date -Format "u" $convRestartTime = Get-Date $restartTime -Format "u" $waitTime=[decimal]::Round((New-TimeSpan -Start $currDate -End $convRestartTime).TotalSeconds)

RebeccaMbulaMs commented 3 months ago

Hi! Thanks for bringing it up. I've created a bug for investigation on this (49779131).