PowerShell 6.1 Cookbook Error: reboot[powershell] resource not found

We updated some of the cookbooks on our Chef server recently which included the PowerShell cookbook version 6.1.  The main new feature of version 6.1 is to install PowerShell 5.1 instead of PowerShell 5.0. 

After updating the cookbooks, we started receiving the following error in our chef-client run:

       [2017-07-31T05:23:42-07:00] FATAL: Chef::Exceptions::ResourceNotFound: resource windows_package[Windows Managemen
t Framework Core 5.1] is configured to notify resource reboot with action reboot_now, but reboot
  cannot be found in the resource collection. windows_package[Windows Management Framework Core 5.1] is defined in C:/Use
rs/vagrant/AppData/Local/Temp/kitchen/cache/cookbooks/powershell/recipes/powershell5.rb:40:in `from_file’

The simple workaround to the issue was to uninstall PowerShell cookbook version 6.1 and roll back to version 6.0.

The Fix

After digging into the PowerShell cookbook further it appears this only effects Windows version 6.1 which would include Windows 7 and Windows Server 2008.  The root cause is the reboot recipe is not included inside or before the if Windows 6.1 if block.  This recipe is only included if the Windows version is greater than 6.1.

I fixed the recipe by moving the include above the if statement and validated the fix in my local kitchen environment and also unit tests. Here is the pull request I created with the fix:


Hopefully the Chef team will review and accept the PR quickly.

If this was helpful or you have further questions please leave a comment below.

Leave a Reply