Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

powershell_script failing with "powershell.exe"' is not recognized as an internal or external command #2009

Closed
p-palanisamy opened this issue Sep 6, 2014 · 4 comments

Comments

@p-palanisamy
Copy link

powershell_script resource is failing with PATH issue where it doesn't find the location of powershell.exe.

Target OS: Windows 2012
Chef Client: 11.14.6
Chef Server: 11.1.0

Stacktrace:

Generated at 2014-09-06 13:58:26 +0000
Mixlib::ShellOut::ShellCommandFailed: powershell_script[Set DNS SearchList] (tr::set-dns-search-list line 15) had an error: Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [0], but received '1'
---- Begin output of "powershell.exe" -NoLogo -NonInteractive -NoProfile -ExecutionPolicy RemoteSigned -InputFormat None -File "C:/Users/ADMINI~1/AppData/Local/Temp/chef-script20140906-2424-4bkq0u.ps1" ----
STDOUT: 
STDERR: '"powershell.exe"' is not recognized as an internal or external command,

operable program or batch file.
---- End output of "powershell.exe" -NoLogo -NonInteractive -NoProfile -ExecutionPolicy RemoteSigned -InputFormat None -File "C:/Users/ADMINI~1/AppData/Local/Temp/chef-script20140906-2424-4bkq0u.ps1" ----
Ran "powershell.exe" -NoLogo -NonInteractive -NoProfile -ExecutionPolicy RemoteSigned -InputFormat None -File "C:/Users/ADMINI~1/AppData/Local/Temp/chef-script20140906-2424-4bkq0u.ps1" returned 1
C:/opscode/chef/embedded/lib/ruby/gems/1.9.1/gems/mixlib-shellout-1.4.0-x86-mingw32/lib/mixlib/shellout.rb:257:in `invalid!'
C:/opscode/chef/embedded/lib/ruby/gems/1.9.1/gems/mixlib-shellout-1.4.0-x86-mingw32/lib/mixlib/shellout.rb:244:in `error!'
C:/opscode/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.14.6-x86-mingw32/lib/chef/mixin/shell_out.rb:43:in `shell_out!'
C:/opscode/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.14.6-x86-mingw32/lib/chef/provider/execute.rb:60:in `block in action_run'
C:/opscode/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.14.6-x86-mingw32/lib/chef/mixin/why_run.rb:52:in `call'
C:/opscode/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.14.6-x86-mingw32/lib/chef/mixin/why_run.rb:52:in `add_action'
C:/opscode/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.14.6-x86-mingw32/lib/chef/provider.rb:156:in `converge_by'
C:/opscode/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.14.6-x86-mingw32/lib/chef/provider/execute.rb:59:in `action_run'
C:/opscode/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.14.6-x86-mingw32/lib/chef/provider/script.rb:38:in `action_run'
C:/opscode/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.14.6-x86-mingw32/lib/chef/provider/windows_script.rb:56:in `action_run'
C:/opscode/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.14.6-x86-mingw32/lib/chef/provider.rb:121:in `run_action'
C:/opscode/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.14.6-x86-mingw32/lib/chef/resource.rb:648:in `run_action'
C:/opscode/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.14.6-x86-mingw32/lib/chef/runner.rb:49:in `run_action'
C:/opscode/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.14.6-x86-mingw32/lib/chef/runner.rb:81:in `block (2 levels) in converge'
C:/opscode/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.14.6-x86-mingw32/lib/chef/runner.rb:81:in `each'
C:/opscode/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.14.6-x86-mingw32/lib/chef/runner.rb:81:in `block in converge'
C:/opscode/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.14.6-x86-mingw32/lib/chef/resource_collection.rb:98:in `block in execute_each_resource'
C:/opscode/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.14.6-x86-mingw32/lib/chef/resource_collection/stepable_iterator.rb:116:in `call'
C:/opscode/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.14.6-x86-mingw32/lib/chef/resource_collection/stepable_iterator.rb:116:in `call_iterator_block'
C:/opscode/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.14.6-x86-mingw32/lib/chef/resource_collection/stepable_iterator.rb:85:in `step'
C:/opscode/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.14.6-x86-mingw32/lib/chef/resource_collection/stepable_iterator.rb:104:in `iterate'
C:/opscode/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.14.6-x86-mingw32/lib/chef/resource_collection/stepable_iterator.rb:55:in `each_with_index'
C:/opscode/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.14.6-x86-mingw32/lib/chef/resource_collection.rb:96:in `execute_each_resource'
C:/opscode/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.14.6-x86-mingw32/lib/chef/runner.rb:80:in `converge'
C:/opscode/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.14.6-x86-mingw32/lib/chef/client.rb:345:in `converge'
C:/opscode/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.14.6-x86-mingw32/lib/chef/client.rb:431:in `do_run'
C:/opscode/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.14.6-x86-mingw32/lib/chef/client.rb:227:in `run'
C:/opscode/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.14.6-x86-mingw32/lib/chef/application.rb:236:in `run_chef_client'
C:/opscode/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.14.6-x86-mingw32/lib/chef/application/client.rb:338:in `block in run_application'
C:/opscode/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.14.6-x86-mingw32/lib/chef/application/client.rb:327:in `loop'
C:/opscode/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.14.6-x86-mingw32/lib/chef/application/client.rb:327:in `run_application'
C:/opscode/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.14.6-x86-mingw32/lib/chef/application.rb:55:in `run'
C:/opscode/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.14.6-x86-mingw32/bin/chef-client:26:in `<top (required)>'
C:/opscode/chef/bin/chef-client:23:in `load'
C:/opscode/chef/bin/chef-client:23:in `<main>'
@p-palanisamy
Copy link
Author

When cwd "C:\\Windows\\System32\\WindowsPowerShell\\v1.0" is been specified powershell is getting executed but other commands mentioned in the code block is failing as unrecognized.

When I echoed the $env:Path inside the code block, it properly prints the contents of the environment variable PATH.
C:\7-zip;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;C:\Program Files\Amazon\cfn-bootstrap\;C:\opscode\chef\bin;C:\opscode\chef\embedded\bin

@p-palanisamy
Copy link
Author

This appears to be because of the problem addressed in the pull request - #1876

We are adding a path to environment variable PATH using windows_path and after that the problem started.

When this pull request is expected to be merged and a new client build will be released?

@btm
Copy link
Contributor

btm commented Sep 9, 2014

@jdmundrawala is working on a patch to include in the Windows cookbook that will work around this issue for now. I would expect we could release that this week.

chef-boneyard/windows#112

@btm
Copy link
Contributor

btm commented Dec 12, 2014

This was fixed by #2024. Anyone experiencing any environment issues should be sure they replicate on 11.16.4 or later.

@btm btm closed this as completed Dec 12, 2014
@chef chef locked and limited conversation to collaborators Nov 16, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants