summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Smith <tsmith84@gmail.com>2020-02-28 12:24:14 -0800
committerTim Smith <tsmith84@gmail.com>2020-02-28 12:24:14 -0800
commitd0cea51cf1e135ae654ff0eb7d676babb757e0a8 (patch)
treeb26cc9fbb40efe107746bf1b643a9cc9e6e5ac3b
parent7b7d1556dfdcbec9b78334b89ec8fae35e709fc0 (diff)
downloadchef-remove_ps_bypass_check.tar.gz
Deprecate supports_powershell_execution_bypass? checkremove_ps_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>
-rw-r--r--lib/chef/platform/query_helpers.rb4
-rw-r--r--lib/chef/resource/powershell_script.rb20
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