diff options
-rw-r--r-- | lib/chef/platform/query_helpers.rb | 4 | ||||
-rw-r--r-- | lib/chef/resource/powershell_script.rb | 20 |
2 files changed, 7 insertions, 17 deletions
diff --git a/lib/chef/platform/query_helpers.rb b/lib/chef/platform/query_helpers.rb index 3cce4b5d2c..a55ca43bc8 100644 --- a/lib/chef/platform/query_helpers.rb +++ b/lib/chef/platform/query_helpers.rb @@ -66,9 +66,9 @@ class Chef end end + # @deprecated we don't support any release of Windows that isn't PS 3+ def supports_powershell_execution_bypass?(node) - node[:languages] && node[:languages][:powershell] && - node[:languages][:powershell][:version].to_i >= 3 + true end def supports_dsc?(node) diff --git a/lib/chef/resource/powershell_script.rb b/lib/chef/resource/powershell_script.rb index 6cb1453376..5e0a961c2a 100644 --- a/lib/chef/resource/powershell_script.rb +++ b/lib/chef/resource/powershell_script.rb @@ -71,24 +71,14 @@ class Chef end # Options that will be passed to Windows PowerShell command + # + # @returns [String] def default_flags return "" if Chef::Platform.windows_nano_server? - # Execution policy 'Bypass' is preferable since it doesn't require - # user input confirmation for files such as PowerShell modules - # downloaded from the Internet. However, 'Bypass' is not supported - # prior to PowerShell 3.0, so the fallback is 'Unrestricted' - execution_policy = Chef::Platform.supports_powershell_execution_bypass?(run_context.node) ? "Bypass" : "Unrestricted" - - [ - "-NoLogo", - "-NonInteractive", - "-NoProfile", - "-ExecutionPolicy #{execution_policy}", - # PowerShell will hang if STDIN is redirected - # http://connect.microsoft.com/PowerShell/feedback/details/572313/powershell-exe-can-hang-if-stdin-is-redirected - "-InputFormat None", - ].join(" ") + # Set InputFormat to None as PowerShell will hang if STDIN is redirected + # http://connect.microsoft.com/PowerShell/feedback/details/572313/powershell-exe-can-hang-if-stdin-is-redirected + "-NoLogo -NonInteractive -NoProfile -ExecutionPolicy Bypass -InputFormat None" end end end |