sous-chefs / powershell

Development repository for the powershell cookbook
https://supermarket.chef.io/cookbooks/powershell
Apache License 2.0
110 stars 88 forks source link

Powershell5 install on Windows Server 2012 R2 returns exit code '5' #47

Closed rschiefer closed 9 years ago

rschiefer commented 9 years ago

What does an exit code of '5' mean?

================================================================================ Error executing action install on resource 'windows_package[Windows Management Framework Core 5.0]'

       Mixlib::ShellOut::ShellCommandFailed
       ------------------------------------
       Expected process to exit with [0, 42, 127, 3010], but received '5'
       ---- Begin output of start "" /wait "C:\Users\ADMINI~1\AppData\Local\Temp\kitchen\cache\WindowsBlue-KB3037315

-x64.msu" /quiet /norestart & exit %%ERRORLEVEL%% ---- STDOUT: STDERR: ---- End output of start "" /wait "C:\Users\ADMINI~1\AppData\Local\Temp\kitchen\cache\WindowsBlue-KB3037315-x 64.msu" /quiet /norestart & exit %%ERRORLEVEL%% ---- Ran start "" /wait "C:\Users\ADMINI~1\AppData\Local\Temp\kitchen\cache\WindowsBlue-KB3037315-x64.msu" /quiet /norestart & exit %%ERRORLEVEL%% returned 5

smurawski commented 9 years ago

The default test-kitchen runs invoke chef-client over WinRM. The windows security model does not allow the installation of MSU packages over WinRM.

For more, see https://github.com/test-kitchen/test-kitchen/issues/655#issuecomment-114921207

mrswadge commented 5 years ago

I've just been struggling with this, some background to the above statement.

https://support.microsoft.com/en-us/help/2773898/windows-update-standalone-installer-wusa-returns-0x5-error-access-deni

Having trawled through https://github.com/chef/chef/issues/1614, they mention there is msu_package since Chef Client 12.17 (https://docs.chef.io/resource_msu_package.html).

I tried modifying recipe/powershell5.rb to say (and the block for 6.1) and it worked for me.

  elsif ::Windows::VersionHelper.nt_version(node) > 6.1
    msu_package 'Windows Management Framework Core 5.1' do # ~FC009
      source node['powershell']['powershell5']['url']
      checksum node['powershell']['powershell5']['checksum']
      action :install
      notifies :reboot_now, 'reboot[powershell]', :immediately if node['powershell']['installation_reboot_mode'] != 'no_reboot'
      not_if { ::Powershell::VersionHelper.powershell_version?(node['powershell']['powershell5']['version']) }
    end