diff options
author | mwrock <matt@mattwrock.com> | 2020-10-07 11:02:54 -0700 |
---|---|---|
committer | mwrock <matt@mattwrock.com> | 2020-10-07 11:02:54 -0700 |
commit | 03f70aede103ffdea053affff3231c2b07fcebe9 (patch) | |
tree | 8c47753057f9aa81ef1da0e68f2f10b14b3b9341 /lib/chef/provider/powershell_script.rb | |
parent | 0e268d038575d781ff396ce6307a20834ef52cae (diff) | |
download | chef-ps_script.tar.gz |
add interpreter to handle pwsh and powershell to powershell_scriptps_script
Signed-off-by: mwrock <matt@mattwrock.com>
Diffstat (limited to 'lib/chef/provider/powershell_script.rb')
-rw-r--r-- | lib/chef/provider/powershell_script.rb | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/lib/chef/provider/powershell_script.rb b/lib/chef/provider/powershell_script.rb index 49d800b6d2..8360dd873b 100644 --- a/lib/chef/provider/powershell_script.rb +++ b/lib/chef/provider/powershell_script.rb @@ -54,7 +54,18 @@ class Chef def interpreter_path # Powershell.exe is always in "v1.0" folder (for backwards compatibility) - Chef::Util::PathHelper.join(basepath, "WindowsPowerShell", "v1.0", interpreter) + # pwsh is the other interpreter and we will assume that it is on the path. + # It will exist in different folders depending on the installed version. + # There can also be multiple versions installed. Depending on how it was installed, + # there might be a registry entry pointing to the installation path. The key will + # differ depending on version and architecture. It seems best to let the PATH + # determine the file path to use since that will provide the same pwsh.exe one + # would invoke from any shell. + if interpreter == "powershell" + Chef::Util::PathHelper.join(basepath, "WindowsPowerShell", "v1.0", "#{interpreter}.exe") + else + interpreter + end end def code |