> For the complete documentation index, see [llms.txt](https://docs.octoxlabs.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.octoxlabs.com/action-center/windows/run-command.md).

# Run Command

Runs one PowerShell command on each Windows device the workflow collected. The job connects to the device over WinRM using the IP addresses stored on the asset, with the same username and password for every device.

### Before you begin

* WinRM reachable on the devices: the job tries port 5985 (HTTP) and port 5986 (HTTPS) and authenticates with NTLM.
* A Windows account that is allowed to run the command on every targeted device.
* Asset type: `device` only.
* Required columns: `Hostname` and `IpAddresses`. Devices without both are left out.
* A condition node before the job, so that devices are collected for it to act on.
* Job Settings defaults are described in [Action Center Settings](broken://pages/b0db97c7083665e2fade4a5e1253df7ea527db04).

{% hint style="warning" %}
The command runs on every collected device, with the account you enter. Test it on one device first, using a condition that matches a single host.
{% endhint %}

### Settings

| Setting        | Type | Required | Default | Description                                                                                |
| -------------- | ---- | -------- | ------- | ------------------------------------------------------------------------------------------ |
| Username       | Text | Yes      | None    | Account used to connect to every device.                                                   |
| Password       | Text | Yes      | None    | Password of that account. The field is not marked sensitive, so it is shown as plain text. |
| Command To Run | Text | Yes      | None    | The PowerShell command to run on each device.                                              |

These three fields have no label in the code, so the names above are derived from the field names (`username`, `password`, `command_to_run`).

### How it works

The job works per device. For each device it goes through the addresses in `IpAddresses`. For each address it first tries HTTP on port 5985, then HTTPS on port 5986 if the HTTP attempt fails, and runs the command through PowerShell. When the command returns exit code 0 on one protocol, the other protocol is not tried for that address. The job then continues with the next address and the next device, so a device with several addresses can run the command more than once.

Errors are not raised. A failed connection or a non-zero exit code is skipped (the exit code failure is written to the debug log), so the job does not fail and the workflow continues. The command output is not captured or passed on.

When it finishes, the job passes the assets it received on to the next node unchanged.

### Example

```
Username:       EXAMPLE\svc-octo
Password:       YOUR_PASSWORD
Command To Run: Restart-Service -Name Spooler
```

### What's next?

<table data-view="cards"><thead><tr><th></th><th></th><th data-hidden data-card-target data-type="content-ref"></th></tr></thead><tbody><tr><td><strong>About Action Center</strong></td><td>Workflows, triggers, conditions and job nodes.</td><td><a href="broken://pages/1ac66f09f2d20b027acd60eb7888183c338d1e94">Broken link</a></td></tr><tr><td><strong>Action Center Settings</strong></td><td>Save default values and SSH connections for jobs.</td><td><a href="broken://pages/b0db97c7083665e2fade4a5e1253df7ea527db04">Broken link</a></td></tr><tr><td><strong>Copy To (Windows)</strong></td><td>Write a CSV or JSON file to a Windows machine over WinRM.</td><td><a href="broken://pages/40dfd1893800dd475cb805baa3b3743bb864c683">Broken link</a></td></tr><tr><td><strong>Copy To</strong></td><td>Upload device data to a Linux server over SSH.</td><td><a href="broken://pages/3411b99d03b96665dfb94e8e59f50973bc350081">Broken link</a></td></tr></tbody></table>

{% hint style="info" %}
Available starting from version 6.0.0.
{% endhint %}
