summaryrefslogtreecommitdiff
path: root/lib/chef/provider/package/powershell.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/chef/provider/package/powershell.rb')
-rw-r--r--lib/chef/provider/package/powershell.rb6
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/chef/provider/package/powershell.rb b/lib/chef/provider/package/powershell.rb
index 5c002af806..60244c62e5 100644
--- a/lib/chef/provider/package/powershell.rb
+++ b/lib/chef/provider/package/powershell.rb
@@ -53,6 +53,9 @@ class Chef
# Installs the package specified with the version passed else latest version will be installed
def install_package(names, versions)
+ # To enable tls 1.2, which is disabled by default in some OS
+ powershell_out("[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12")
+
names.each_with_index do |name, index|
cmd = powershell_out(build_powershell_package_command("Install-Package '#{name}'", versions[index]), timeout: new_resource.timeout)
next if cmd.nil?
@@ -115,7 +118,8 @@ class Chef
command = [command] unless command.is_a?(Array)
cmdlet_name = command.first
command.unshift("(")
- %w{-Force -ForceBootstrap}.each do |arg|
+ # -WarningAction SilentlyContinue is used to suppress the warnings from stdout
+ %w{-Force -ForceBootstrap -WarningAction SilentlyContinue}.each do |arg|
command.push(arg)
end
command.push("-RequiredVersion #{version}") if version