WinRM (Windows Remote Management) Connector can be used to execute commands on remote Windows server machine using Microsoft implementation of WS-Management Protocol.

Features

  • Based on standardized Microsoft implementation of WS-Management protocol
  • Password based authentication mechanism
  • Both HTTP and HTTPS protocol support
  • Direct access to the command execution results from the remote server
  • The ability to set connector execution timeouts
  • Synchronous/Asynchronous execution of the connector

Connector Configuration

Configuration parameters- config(JSON)
ParameterDescriptionRequired
hostnameHost name or ip-address of the host server machine to connecttrue: config/request
userConnect with specified username, host server machine authenticationtrue: config/request
passwordConnect with specified password, host server machine authenticationtrue: config/request
protocolConnect with specified protocol, host server machine authentication. Default protocol is httptrue: request
commandCommand to be executed on the host server machinetrue: request
portPort to connect to the host server machine. Default port is 5985 for HTTP and 5986 for HTTPStrue: request
actionAction to be performed exetrue: request
timeoutExecution time for the command in milliseconds. Default timeout is 60000 millisecondsfalse: request
Example
{
  "hostname": "192.156.2.3",
  "user": "Administrator",
  "password": "example123",
  "protocol": "http",
  "command": "dir",
  "port": 5985,
  "action":"exe"
  "timeout": 60000
}

 

Actions

exe

Execute commands on Remote Windows Server

Request parameters

ParameterDescriptionrequired
connector-nameName of the WinRM Connector to be configuredtrue
hostnameHost name or ip-address of the host server machine to connecttrue
userConnect with specified username, host server machine authenticationtrue
passwordConnect with specified password, host server machine authenticationtrue
protocolConnect with specified protocol, host server machine authentication. Default protocol is httptrue
commandCommand to be executed on the host server machinetrue
portPort to connect to the host server machine. Default port is 5985 for HTTP and 5986 for HTTPStrue
actionAction to be performed exetrue: request
timeoutExecution time of the Command in milliseconds. Default timeout is 60000 millisecondsfalse

Response parameters

ParameterDescriptionrequired
outputOutput results as per the command executedtrue
exit-statusExit status of the command executedtrue
errorError results as per the command executedtrue

Example

response=@call.connector("my-winrm-connector")
              .set("hostname","192.156.2.3")
              .set("user","Administrator")
              .set("password","example123")
              .set("protocol","http")
              .set("command","dir")
              .set("port", 5985)
              .set("timeout",10000)
              .sync

#WinRM Connector Response Parameters
result=response.get("output")                    #Output
result=response.get("exit-status")               #Exit status
result=response.get("error")                     #Error output

 

HTTP Configurations

Http Configurations Please refer the link and fire the commands on the windows server which you want to connect through the http protocol.

HTTPS Configurations

Https Configurations

$VerbosePreference = "Continue"

Enable-PSRemoting -SkipNetworkProfileCheck -Force

Fire the above commands before on the windows server before running the powershell script.

Please refer the above link and run the powerscript on the windows server which you want to connect through the https protocol.

Connector request error handling

This is how success or failures can be handled for the connector requests within your Flintbit. This would help to take appropriate action if something failed.

if response.exitcode == 0               # 0 is success.
  puts "success"
  # take action in case of success
else                                    # non zero means fail
  puts "fail"
  puts "Reason:" + response.message     # get the reason of failure
  ## Take action in case of failure
end

On this page: