diff --git a/plugins/commands/ps/command.rb b/plugins/commands/ps/command.rb index 33eeec253..3bcc41ba8 100644 --- a/plugins/commands/ps/command.rb +++ b/plugins/commands/ps/command.rb @@ -45,16 +45,16 @@ module VagrantPlugins raise Vagrant::Errors::VMNotCreatedError end - if machine.config.vm.communicator != :winrm #|| !machine.provider.capability?(:winrm_info) + if machine.config.vm.communicator != :winrm raise VagrantPlugins::CommunicatorWinRM::Errors::WinRMNotReady end if !options[:command].nil? - out_code = machine.communicate.execute options[:command] + out_code = machine.communicate.execute(options[:command]) if out_code == 0 machine.ui.detail("Command: #{options[:command]} executed succesfully with output code #{out_code}.") end - break + next end ps_info = VagrantPlugins::CommunicatorWinRM::Helper.winrm_info(machine) @@ -63,7 +63,7 @@ module VagrantPlugins # Extra arguments if we have any ps_info[:extra_args] = options[:extra_args] - result = ready_ps_remoting_for machine, ps_info + result = ready_ps_remoting_for(machine, ps_info) machine.ui.detail( "Creating powershell session to #{ps_info[:host]}:#{ps_info[:port]}") @@ -73,7 +73,7 @@ module VagrantPlugins @env.host.capability(:ps_client, ps_info) ensure if !result["PreviousTrustedHosts"].nil? - reset_ps_remoting_for machine, ps_info + reset_ps_remoting_for(machine, ps_info) end end end diff --git a/plugins/commands/ps/plugin.rb b/plugins/commands/ps/plugin.rb index 56b84b3c5..847b82c47 100644 --- a/plugins/commands/ps/plugin.rb +++ b/plugins/commands/ps/plugin.rb @@ -7,12 +7,12 @@ module VagrantPlugins class Plugin < Vagrant.plugin("2") name "ps command" description <<-DESC - The ps command opens a remote powershell session to the + The ps command opens a remote PowerShell session to the machine if it supports powershell remoting. DESC command("ps") do - require File.expand_path("../command", __FILE__) + require_relative "../command" init! Command end @@ -21,8 +21,7 @@ module VagrantPlugins def self.init! return if defined?(@_init) - I18n.load_path << File.expand_path( - "templates/locales/command_ps.yml", Vagrant.source_root) + I18n.load_path << File.expand_path("templates/locales/command_ps.yml", Vagrant.source_root) I18n.reload! @_init = true end diff --git a/plugins/communicators/winrm/shell.rb b/plugins/communicators/winrm/shell.rb index d9d5f28ce..784660b5e 100644 --- a/plugins/communicators/winrm/shell.rb +++ b/plugins/communicators/winrm/shell.rb @@ -9,7 +9,7 @@ Vagrant::Util::SilenceWarnings.silence! do require "winrm" end -require "winrm-fs/file_manager" +require "winrm-fs" module VagrantPlugins module CommunicatorWinRM diff --git a/templates/locales/command_ps.yml b/templates/locales/command_ps.yml index e30e5246c..51bf666cc 100644 --- a/templates/locales/command_ps.yml +++ b/templates/locales/command_ps.yml @@ -1,16 +1,16 @@ en: vagrant_ps: detecting: |- - Detecting if a remote powershell connection can be made with the guest... + Detecting if a remote PowerShell connection can be made with the guest... reseting: |- Reseting WinRM TrustedHosts to their original value. errors: host_unsupported: |- - Your host does not support powershell. A remote powershell connection + Your host does not support PowerShell. A remote PowerShell connection can only be made from a windows host. ps_remoting_undetected: |- - Unable to establish a remote powershell connection with the guest. + Unable to establish a remote PowerShell connection with the guest. Check if the firewall rules on the guest allow connections to the - windows remote management service. + Windows remote management service.