summaryrefslogtreecommitdiff
path: root/lib/chef/util
diff options
context:
space:
mode:
authorJay Mundrawala <jdmundrawala@gmail.com>2015-03-11 16:40:47 -0700
committerJay Mundrawala <jdmundrawala@gmail.com>2015-03-20 14:38:04 -0700
commit2cfc73bb1370623e04b5844e5e4a766e27ba3247 (patch)
tree9c8eff982b20f23b9d4f45715263de1269c81e28 /lib/chef/util
parentc45107e4b0441ae6ce590a754880d8c33969ba20 (diff)
downloadchef-2cfc73bb1370623e04b5844e5e4a766e27ba3247.tar.gz
Add verbose stream
Diffstat (limited to 'lib/chef/util')
-rw-r--r--lib/chef/util/powershell/cmdlet.rb9
1 files changed, 6 insertions, 3 deletions
diff --git a/lib/chef/util/powershell/cmdlet.rb b/lib/chef/util/powershell/cmdlet.rb
index beab55f16f..47d63a2b85 100644
--- a/lib/chef/util/powershell/cmdlet.rb
+++ b/lib/chef/util/powershell/cmdlet.rb
@@ -48,7 +48,9 @@ class Powershell
attr_reader :output_format
def run(switches={}, execution_options={}, *arguments)
- streams = { :json => CmdletStream.new('json') }
+ streams = { :json => CmdletStream.new('json'),
+ :verbose => CmdletStream.new('verbose'),
+ }
arguments_string = arguments.join(' ')
@@ -62,11 +64,12 @@ class Powershell
json_command = @json_format ? " | convertto-json -compress -depth #{json_depth} "\
"> #{streams[:json].path}" : ""
-
+ redirections = "4> '#{streams[:verbose].path}'"
command_string = "powershell.exe -executionpolicy bypass -noprofile -noninteractive "\
"-command \"trap [Exception] {write-error -exception "\
"($_.Exception.Message);exit 1};#{@cmdlet} #{switches_string} "\
- "#{arguments_string}#{json_command}\";if ( ! $? ) { exit 1 }"
+ "#{arguments_string} #{redirections}"\
+ "#{json_command}\";if ( ! $? ) { exit 1 }"
augmented_options = {:returns => [0], :live_stream => false}.merge(execution_options)
command = Mixlib::ShellOut.new(command_string, augmented_options)