lib/chef/knife/winrm_session.rb in knife-windows-1.6.0 vs lib/chef/knife/winrm_session.rb in knife-windows-1.7.0
- old
+ new
@@ -29,11 +29,12 @@
configure_proxy
@host = options[:host]
@port = options[:port]
@user = options[:user]
- @shell = options[:shell]
+ @shell_args = [ options[:shell] ]
+ @shell_args << { codepage: options[:codepage] } if options[:shell] == :cmd
url = "#{options[:host]}:#{options[:port]}/wsman"
scheme = options[:transport] == :ssl ? 'https' : 'http'
@endpoint = "#{scheme}://#{url}"
opts = Hash.new
@@ -61,10 +62,10 @@
Chef::HTTP::DefaultSSLPolicy.new(http_client.ssl_config).set_custom_certs
end
def relay_command(command)
session_result = WinRM::Output.new
- @winrm_session.shell(@shell) do |shell|
+ @winrm_session.shell(*@shell_args) do |shell|
shell.username = @user.split("\\").last if shell.respond_to?(:username)
session_result = shell.run(command) do |stdout, stderr|
print_data(@host, stdout) if stdout
print_data(@host, stderr, :red) if stderr
end