Class: WinRM::WinRM

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/winrm.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeWinRM

Returns a new instance of WinRM.



75
76
77
# File 'lib/winrm.rb', line 75

def initialize
  @winrm = SOAP::WinRMWebService.new
end

Instance Attribute Details

#winrmObject (readonly)

Returns the value of attribute winrm.



39
40
41
# File 'lib/winrm.rb', line 39

def winrm
  @winrm
end

Class Method Details

.endpointObject

Fetch the current endpoint



52
53
54
# File 'lib/winrm.rb', line 52

def self.endpoint
  @@endpoint
end

.endpoint=(endpoint, version = 2) ⇒ Object

Set the endpoint for WinRM Web Services.

Parameters:

  • endpoint (String)

    The URL of the endpoint. myserver:5986/wsman

  • version (Integer) (defaults to: 2)

    The SOAP version to use. This defaults to 1 and you should not need to pass this parameter.



46
47
48
49
# File 'lib/winrm.rb', line 46

def self.endpoint=(endpoint, version = 2)
  @@endpoint = endpoint
  SOAP::WinRMWebService.endpoint(:uri => endpoint, :version => version)
end

.set_auth(user, pass) ⇒ Object

Set the SOAP username and password.

Parameters:

  • user (String)

    The user name

  • pass (String)

    The password



59
60
61
62
# File 'lib/winrm.rb', line 59

def self.set_auth(user,pass)
  @@user = user
  SOAP::WinRMWebService.set_auth(user,pass)
end

.set_ca_trust_path(path) ⇒ Object



64
65
66
# File 'lib/winrm.rb', line 64

def self.set_ca_trust_path(path)
  SOAP::WinRMWebService.set_ca_trust_path(path)
end

.set_http_driver(driver) ⇒ Object

Set the http driver that the SOAP back-end will use.

Parameters:

  • driver (Symbol)

    The HTTP driver. Available drivers: :curb, :net_http, :http_client(Default)



71
72
73
# File 'lib/winrm.rb', line 71

def self.set_http_driver(driver)
  Handsoap.http_driver = driver
end

Instance Method Details

#cmd(command) ⇒ Object

Run a CMD command



81
82
83
# File 'lib/winrm.rb', line 81

def cmd(command)
  @winrm.run_cmd(command)
end

#powershell(script_file) ⇒ Object

Run a Powershell script



87
88
89
# File 'lib/winrm.rb', line 87

def powershell(script_file)
  @winrm.run_powershell_script(script_file)
end

#wql(wql) ⇒ Object

Run a WQL Query



94
95
96
# File 'lib/winrm.rb', line 94

def wql(wql)
  @winrm.run_wql(wql)
end