xWindowsUpdate icon indicating copy to clipboard operation
xWindowsUpdate copied to clipboard

xWindowsUpdateAgent: Improve the UpdateNow parameter description

Open ewhitesides opened this issue 7 years ago • 1 comments

Also, it would be helpful to state the long term behavior in the Readme :

if I apply a configuration with UpdateNow = $true, will the server

-continue to apply updates after the initial set-dscconfiguration based on what the LCM mode is. -report errors in the future in the DSC Operational Logs if there are new available updates?

ewhitesides avatar Jun 08 '18 16:06 ewhitesides

Looking at the code it seems like this to me:

Updated text and removed errors.

Get-TargetResource

If UpdateNow is set to $true, Get-TargetResource will check how many updates there are to install and return that in TotalUpdatesNotInstalled. Get-TargetResource will return $true for UpdateNow if there zero updates and no reboot is required, otherwise Get-TargetResource returns $false. Logic here seems off?

https://github.com/PowerShell/xWindowsUpdate/blob/1afc7a4a45c7eea5e46a01e562860b050b58aa27/DscResources/MSFT_xWindowsUpdateAgent/MSFT_xWindowsUpdateAgent.psm1#L361-L375

Test-TargetResource

If UpdateNow is set to $true, and Get-TargetResource returns UpdateNow = $true, Test-TargetResource returns $true, otherwise Test-TargetResource returns $false. This is why the logic seems of in Get-TargetResource, feels like Test-TargetResource has reversed logic.

https://github.com/PowerShell/xWindowsUpdate/blob/1afc7a4a45c7eea5e46a01e562860b050b58aa27/DscResources/MSFT_xWindowsUpdateAgent/MSFT_xWindowsUpdateAgent.psm1#L548-L561

Set-TargetResource

Same logic as in Test-TargetResource.

https://github.com/PowerShell/xWindowsUpdate/blob/1afc7a4a45c7eea5e46a01e562860b050b58aa27/DscResources/MSFT_xWindowsUpdateAgent/MSFT_xWindowsUpdateAgent.psm1#L440-L464

Summary

I think it should (meant to) continuously update as long as Get-WuaSearcher returns that there are updates to be installed.

johlju avatar Jun 09 '18 13:06 johlju