Mar 28 2024 09:30 AM - edited Mar 28 2024 09:37 AM
Hi guys,
I've encountered an issue about scheduled reboot for windows updates installation via WAC.
If I install any patch and schedule the reboot the sever will always reboot immediately after patch installation.
After some digging, I think I know where the problem resides, but don't know where else to file a bug report.
The PS module named Microsoft.SME.WindowsUpdate defines the function "Install-WACWUWindowsUpdates" with a parameter for $restartTime.
When using WAC, the javascript takes your $restartTime 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.
Example:
This line is from the PS script WAC created on the managed server to trigger the updates, the scheduled reboot time is stated as below:
$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 will not work for all servers where regional format data is not the same as the "en-US" standard.
I've also tried to elaborate some fix, using the "-Format" option for the Get-Date command:
$currdate = Get-Date -Format "u"
$convRestartTime = Get-Date $restartTime -Format "u"
$waitTime=[decimal]::Round((New-TimeSpan -Start $currDate -End $convRestartTime).TotalSeconds)
Trying to simulate my fix, there is no error and the difference between the dates is consistent to the reboot time indicated in the web GUI.
Can someone make this feedback reach the developers of the update extensions in WAC?
Do you have any other suggestion about this issue?
Thanks for any input on this.
Alessandro
Apr 02 2024 12:57 AM
SolutionApr 04 2024 06:24 AM
Apr 04 2024 06:54 AM
Apr 04 2024 08:51 AM
May 20 2024 09:01 AM
Apr 02 2024 12:57 AM
Solution