Method: WinRM::Connection#shell

Defined in:
lib/winrm/connection.rb

#shell(shell_type, shell_opts = {}) ⇒ Shell

Creates a new shell on the remote Windows server associated with this connection.

Parameters:

  • shell_type (Symbol)

    The shell type :cmd or :powershell

  • shell_opts (Hash) (defaults to: {})

    Options targeted for the created shell

Returns:

  • (Shell)

    PowerShell or Cmd shell instance.



38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/winrm/connection.rb', line 38

def shell(shell_type, shell_opts = {})
  shell = shell_factory.create_shell(shell_type, shell_opts)
  if block_given?
    begin
      yield shell
    ensure
      shell.close
    end
  else
    shell
  end
end