# WindowsExecutor Operator

The **WindowsExecutor** operator executes a command on a target Windows machine using WinRM.

The command can be anything that runs on a Windows Command Prompt.

## Operator arguments <a href="#operator-arguments" id="operator-arguments"></a>

| Name        | Type   | Value Restrictions                                                         | Required | Default | Description                                                                          |
| ----------- | ------ | -------------------------------------------------------------------------- | -------- | ------- | ------------------------------------------------------------------------------------ |
| `command`   | String |                                                                            | Yes      |         | The command to be executed on the remote machine                                     |
| `host`      | Object | It should have a structure like the one described here below               | No       |         | Information relative to the target machine onto which the command has to be executed |
| `component` | String | It should match the name of an existing Component of the System under test | No       |         | The name of the Component whose properties can be used as arguments of the operator  |

### `host` structure and arguments <a href="#defining-a-host-for-a-command" id="defining-a-host-for-a-command"></a>

Here follows the structure of the `host` argument

```yaml
host:
  protocol: [https|http]
  hostname: this_is_a_hostname
  port: 5863
  path: /wsman
  username: this_is_a_username
  password: this_is_a_password
  validateCertificate: false
```

with its arguments:

| Name                  | Type    | Value Restrictions                                                          | Required                                                                                                       | Default | Description                                                                                                                                                      |
| --------------------- | ------- | --------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------- | ------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `protocol`            | String  | <ul><li>https</li><li>http</li></ul>                                        | Yes, if the Component whose name is defined in `component` hasn’t a property named `host->protocol`            | https   | The protocol to use to connect to the Windows machine with WinRM                                                                                                 |
| `hostname`            | String  | Valid FQDN or ip address                                                    | Yes, if the Component whose name is defined in `component` hasn’t a property named `host->hostname`            | -       | Windows machine’s hostname                                                                                                                                       |
| `port`                | Number  | 1≤`port`≤65532                                                              | Yes, if the Component whose name is defined in `component` hasn’t a property named `host->port`                | 5863    | WinRM port                                                                                                                                                       |
| `path`                | String  | -                                                                           | Yes, if the Component whose name is defined in `component` hasn’t a property named `host->path`                | /wsman  | The path where WinRM is listening                                                                                                                                |
| `username`            | String  | <ul><li>username</li><li>domain\username</li><li>username\@domain</li></ul> | Yes, if the Component whose name is defined in `component` hasn’t a property named `host->hostname`            | -       | User login (domain or local)                                                                                                                                     |
| `password`            | String  | -                                                                           | Yes, if the Component whose name is defined in `component` hasn’t a property named `host->password`            | -       | Login password                                                                                                                                                   |
| `authType`            | String  | <ul><li>ntlm</li><li>ssl</li></ul>                                          | Yes, if the Component whose name is defined in `component` hasn’t a property named `host->authType`            | ntlm    | The authentication method to use against Windows machine                                                                                                         |
| `validateCertificate` | Boolean | <ul><li>true</li><li>false</li></ul>                                        | Yes, if the Component whose name is defined in `component` hasn’t a property named `host->validateCertificate` | False   | Whether or not validate the server certificate                                                                                                                   |
| `ca`                  | String  | A valid CA certificate                                                      | Yes, if the Component whose name is defined in `component` hasn’t a property named `host->ca`                  | -       | The CA that is required to validate the servier certificate                                                                                                      |
| `operationTimeoutSec` | Integer | Must be greather then 0                                                     | No                                                                                                             |         | <p>The amount in seconds after which the execution of the command is considered failed</p><p>Notice that the ouput of the command doesn’t reset the timeout.</p> |
| `readTimeoutSec`      | Integer | Must be greather then `operationTimeoutSec`                                 | No                                                                                                             |         | The amount of seconds to wait before an HTTP connect/read times out                                                                                              |

### Get operator arguments from `component` <a href="#get-operator-arguments-from-component" id="get-operator-arguments-from-component"></a>

The `component` argument can refer to a Component by name and use its properties as the arguments of the operator. In case the mapped arguments are already provided to the operator, there is no override.

Here is an example of a component that overrides the `host` and the `command` arguments:

```yaml
name: LoadRunnerMachine
componentType: WebApplication
properties:
  command: "dir c:\"
  host:
    hostname: lr.mydomain.com
    username: MyLoadRunnerUser
    password: MyPassword
```

### Examples <a href="#examples" id="examples"></a>

#### Execute a *dir* command with explicit host information <a href="#execute-a-dir-command-with-explicit-host-information" id="execute-a-dir-command-with-explicit-host-information"></a>

```yaml
name: TestConnectivity
operator: WindowsExecutor
arguments:
  command: "dir c:\"
  host:
    hostname: frontend.akamas.io
    username: administrator
    password: MyPassword
```

#### Execute a *dir* command with host information taken from a Component <a href="#execute-a-dir-command-with-host-information-taken-from-a-component" id="execute-a-dir-command-with-host-information-taken-from-a-component"></a>

```yaml
name: TestConnectivity
operator: WindowsExecutor
arguments:
  command: "dir c:\"
  component: frontend1
```
