diff options
author | Tim Smith <tsmith84@gmail.com> | 2020-02-28 12:24:14 -0800 |
---|---|---|
committer | Tim Smith <tsmith84@gmail.com> | 2020-02-28 14:02:26 -0800 |
commit | 2c55b1bf424522fe253e515f6237be130d58859d (patch) | |
tree | 2cda48e4dee7655f22022c1c5afc8ba9f01b4f98 /lib | |
parent | c08cf41a46b7b1f957c6073a73d0a1f2ccc4fce1 (diff) | |
download | chef-2c55b1bf424522fe253e515f6237be130d58859d.tar.gz |
Deprecate supports_powershell_execution_bypass? check
All the platforms we support have PowerShell 3.0+ now so this is always true.
Signed-off-by: Tim Smith <tsmith@chef.io>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/chef/platform/query_helpers.rb | 4 | ||||
-rw-r--r-- | lib/chef/resource/powershell_script.rb | 22 |
2 files changed, 8 insertions, 18 deletions
diff --git a/lib/chef/platform/query_helpers.rb b/lib/chef/platform/query_helpers.rb index 1ddbe09bf4..169d762a45 100644 --- a/lib/chef/platform/query_helpers.rb +++ b/lib/chef/platform/query_helpers.rb @@ -48,9 +48,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 154655f4d9..727ff6609a 100644 --- a/lib/chef/resource/powershell_script.rb +++ b/lib/chef/resource/powershell_script.rb @@ -1,6 +1,6 @@ # # Author:: Adam Edwards (<adamed@chef.io>) -# Copyright:: Copyright 2013-2016, Chef Software Inc. +# Copyright:: Copyright 2013-2020, Chef Software Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -71,22 +71,12 @@ class Chef end # Options that will be passed to Windows PowerShell command + # + # @returns [String] def default_flags - # 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 |