class Train::Extras::PowerShellCommand
this is required if you run locally on windows, winrm connections provide a PowerShell shell automatically TODO: only activate in local mode
Public Class Methods
new(backend, options)
click to toggle source
# File lib/train/extras/command_wrapper.rb, line 107 def initialize(backend, options) @backend = backend validate_options(options) end
Public Instance Methods
run(script)
click to toggle source
# File lib/train/extras/command_wrapper.rb, line 112 def run(script) # wrap the script to ensure we always run it via powershell # especially in local mode, we cannot be sure that we get a Powershell # we may just get a `cmd`. # TODO: we may want to opt for powershell.exe -command instead of `encodeCommand` "powershell -encodedCommand #{WinRM::PowershellScript.new(safe_script(script)).encoded}" end
safe_script(script)
click to toggle source
reused from github.com/WinRb/WinRM/blob/master/lib/winrm/command_executor.rb suppress the progress stream from leaking to stderr
# File lib/train/extras/command_wrapper.rb, line 122 def safe_script(script) "$ProgressPreference='SilentlyContinue';" + script end
to_s()
click to toggle source
# File lib/train/extras/command_wrapper.rb, line 126 def to_s 'PowerShell CommandWrapper' end