> 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/adapters/w/wmi.md).

# WMI

This adapter inventories Windows hosts over WinRM with PowerShell and CIM queries. You can give targets as IP addresses, ranges or CIDR blocks, or let OctoXLabs ask an Active Directory domain controller for all enabled computers. Each reachable host is collected on its own. Unreachable hosts are skipped.

## Use cases

* List the Windows hosts collected over WinRM.

```
Adapters = wmi
```

* Find servers that are in your inventory but not reachable by WMI. Replace `active-directory` with any other source that lists your servers.

```
Adapters = active-directory AND NOT Adapters = wmi
```

## Before you begin

### Network

| Source              | Destination                                          | Port                                               | Protocol |
| ------------------- | ---------------------------------------------------- | -------------------------------------------------- | -------- |
| OctoXLabs connector | Each target Windows host                             | 5985 (HTTP, default) or 5986 (HTTPS), configurable | WinRM    |
| OctoXLabs connector | AD host (domain controller), when used               | Same WinRM port                                    | WinRM    |
| OctoXLabs connector | Domain controller or KDC, when Auth Type is Kerberos | Not verified                                       | Kerberos |

### Required permissions

| Scope or role                     | Permission                                                                 | Needed for                    |
| --------------------------------- | -------------------------------------------------------------------------- | ----------------------------- |
| Dedicated least-privilege account | Remote WinRM and WMI read access on the targets                            | Device inventory              |
| Same account                      | Active Directory read access (the `Get-ADComputer` command) on the AD host | Discovery through **AD Host** |

WinRM must be enabled on every target and reachable from the OctoXLabs host. Installed software is read from the registry. `Win32_Product` is never queried.

## Create credentials in Windows

{% stepper %}
{% step %}

### Enable WinRM

On each target run `Enable-PSRemoting -Force`.
{% endstep %}

{% step %}

### Create the account

Create a dedicated least-privilege domain account with remote WMI and WinRM read access on the targets.
{% endstep %}

{% step %}

### Choose the authentication type

Kerberos is the preferred method in a domain environment. Then set **Kerberos Realm** (uppercase, for example `OCTO.LOCAL`) and **KDC IP**.
{% endstep %}
{% endstepper %}

## Connection parameters

| Parameter                | Required      | Type    | Default | Description                                                                                         |
| ------------------------ | ------------- | ------- | ------- | --------------------------------------------------------------------------------------------------- |
| Targets                  | Conditional   | Text    |         | One IP, a CIDR (`10.0.11.0/24`), a dashed range (`10.0.11.10-50`) or a comma separated list.        |
| AD Host                  | Conditional   | Text    |         | Domain controller (IP or host name). OctoXLabs lists enabled domain computers and inventories each. |
| Port                     | No            | Integer | 5985    | WinRM port. Use 5986 for HTTPS.                                                                     |
| Username                 | Yes           | Text    |         | Account for WinRM. Also used to read AD.                                                            |
| Password                 | Yes           | Text    |         | Account password.                                                                                   |
| Auth Type                | No            | Text    | NTLM    | `Basic`, `Certificate`, `NTLM`, `Kerberos`, `Plaintext`, `SSL` or `Credssp`.                        |
| Is Secure?               | No            | Boolean | False   | Use HTTPS (WinRM over TLS).                                                                         |
| Certificate Verification | No            | Boolean | True    | Validate the server certificate when Is Secure is on.                                               |
| AD Search Base           | No            | Text    |         | LDAP base DN or OU, for example `OU=Servers,DC=octo,DC=local`.                                      |
| Kerberos Realm           | Kerberos only | Text    |         | Uppercase domain. Can be empty if the user name is in UPN format.                                   |
| KDC IP                   | Kerberos only | Text    |         | Domain controller that issues tickets.                                                              |
| Fetch Users              | No            | Boolean | False   | Also collect local accounts and local group memberships (a second WinRM query per host).            |
| Thread Count             | No            | Integer | 32      | Hosts collected in parallel. Min 1, max 32.                                                         |
| Max Targets              | No            | Integer | 4096    | Largest number of hosts Targets may expand to. A larger list is rejected.                           |

Give Targets or AD Host. You can give both.

## Troubleshooting

| Error message                                          | Cause                                          | Fix                                                                          |
| ------------------------------------------------------ | ---------------------------------------------- | ---------------------------------------------------------------------------- |
| Either 'targets' or 'ad\_host' must be provided.       | Neither field is set.                          | Fill Targets or AD Host.                                                     |
| WMI connection test failed for every reachable target. | No target answered the TCP check and `whoami`. | Check WinRM, the port, the firewall and the credentials.                     |
| AD discovery could not reach over WinRM:               | The AD host did not answer.                    | Check the AD host, the port and the credentials.                             |
| AD discovery on returned no parseable computer list:   | `Get-ADComputer` returned no valid JSON.       | Check that the host is a domain controller and that the account can read AD. |

## Change history
