diff options
author | Tor Magnus Rakvåg <tm@intility.no> | 2018-02-08 12:08:28 +0100 |
---|---|---|
committer | Tor Magnus Rakvåg <tm@intility.no> | 2018-02-08 12:08:28 +0100 |
commit | 16a267cb132e0d7d5bed1bf44f0b72ba514b64d3 (patch) | |
tree | 2b87d6458d0f495d4a4c417889c92806529109f3 /lib | |
parent | fa18d9cb1d7d020bbc58a89a947aaae1e85cec00 (diff) | |
download | chef-16a267cb132e0d7d5bed1bf44f0b72ba514b64d3.tar.gz |
simplified powershell_out calls
Signed-off-by: Tor Magnus Rakvåg <tm@intility.no>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/chef/provider/package/powershell.rb | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/lib/chef/provider/package/powershell.rb b/lib/chef/provider/package/powershell.rb index 3912dd23af..f8a7ab69f4 100644 --- a/lib/chef/provider/package/powershell.rb +++ b/lib/chef/provider/package/powershell.rb @@ -65,7 +65,7 @@ class Chef else version = "0" until version.empty? - version = powershell_out( "(Uninstall-Package '#{name}' -Force -ForceBootstrap | select version | Format-Table -HideTableHeaders | Out-String).Trim()", timeout: new_resource.timeout).stdout.strip + version = powershell_out( "(Uninstall-Package '#{name}' -Force -ForceBootstrap).Version", timeout: new_resource.timeout).stdout.strip unless version.empty? Chef::Log.info("Removed package '#{name}' with version #{version}") end @@ -79,9 +79,9 @@ class Chef versions = [] new_resource.package_name.each_with_index do |name, index| version = if new_resource.version && !new_resource.version[index].nil? - powershell_out("(Find-Package '#{name}' -RequiredVersion #{new_resource.version[index]} -ForceBootstrap -Force | select version | Format-Table -HideTableHeaders | Out-String).Trim()", timeout: new_resource.timeout).stdout.strip + powershell_out("(Find-Package '#{name}' -RequiredVersion #{new_resource.version[index]} -ForceBootstrap -Force).Version", timeout: new_resource.timeout).stdout.strip else - powershell_out("(Find-Package '#{name}' -ForceBootstrap -Force | select version | Format-Table -HideTableHeaders | Out-String).Trim()", timeout: new_resource.timeout).stdout.strip + powershell_out("(Find-Package '#{name}' -ForceBootstrap -Force).Version", timeout: new_resource.timeout).stdout.strip end if version.empty? version = nil @@ -96,9 +96,9 @@ class Chef version_list = [] new_resource.package_name.each_with_index do |name, index| version = if new_resource.version && !new_resource.version[index].nil? - powershell_out("(Get-Package -Name '#{name}' -RequiredVersion #{new_resource.version[index]} -ForceBootstrap -Force | select version | Format-Table -HideTableHeaders | Out-String).Trim()", timeout: new_resource.timeout).stdout.strip + powershell_out("(Get-Package -Name '#{name}' -RequiredVersion #{new_resource.version[index]} -ForceBootstrap -Force).Version", timeout: new_resource.timeout).stdout.strip else - powershell_out("(Get-Package -Name '#{name}' -ForceBootstrap -Force | select version | Format-Table -HideTableHeaders | Out-String).Trim()", timeout: new_resource.timeout).stdout.strip + powershell_out("(Get-Package -Name '#{name}' -ForceBootstrap -Force).Version", timeout: new_resource.timeout).stdout.strip end if version.empty? version = nil |