chef-cookbooks / chef_client_updater

Chef Cookbook to update the chef client on nodes
https://supermarket.chef.io/cookbooks/chef_client_updater
Apache License 2.0
54 stars 79 forks source link

#209 Fixed Windows PowerShell task reschedule #210

Closed jwdean closed 4 years ago

jwdean commented 4 years ago

1) Fixed identified defect where $taskScheduler was being used without being fully initialized. The erroring code was ultimately removed due to refactoring to use the Task Scheduler cmdlets introduced in Windows PowerShell 3.0.

2) Using the cmdlets allowed addition of 'StartWhenAvailable' which, when enabled, means the task will run as soon as possible after the trigger time has passed. Previously the task would not have run if the system were rebooting at scheduled time.

2) Updated the start time of the new trigger to be based on the current time rather than the time the trigger last occurred. Task will run $minutes into the future rather than $minutes from the last trigger.

3) Minor spelling correction

No automated tests for this code existed and no automated tests were added. This was manually tested on Windows 7, Windows 10, and Windows Server 2012.

Note that this does create a dependency on Windows PowerShell 3.0 that may not have existed before. PowerShell 3.0 was released in 2012. New installs of the [now unsupported] Windows 7 and Windows Server 2008R2 come with PowerShell 2.0, but can be upgraded well beyond 3.0. https://docs.microsoft.com/en-us/powershell/scripting/powershell-support-lifecycle?view=powershell-7


Developer's Certificate of Origin 1.1

By making a contribution to this project, I certify that:

(a) The contribution was created in whole or in part by me and I have the right to submit it under the open source license indicated in the file; or

(b) The contribution is based upon previous work that, to the best of my knowledge, is covered under an appropriate open source license and I have the right under that license to submit that work with modifications, whether created in whole or in part by me, under the same open source license (unless I am permitted to submit under a different license), as Indicated in the file; or

(c) The contribution was provided directly to me by some other person who certified (a), (b) or (c) and I have not modified it.

(d) I understand and agree that this project and the contribution are public and that a record of the contribution (including all personal information I submit with it, including my sign-off) is maintained indefinitely and may be redistributed consistent with this project or the open source license(s) involved.

Signed-off-by: Jeff Dean jwdean@scriptpro.com