> 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/m/microsoft-hyper-v.md).

# Microsoft Hyper V

Microsoft Hyper V is the hypervisor of Windows Server. OctoXLabs runs `Get-VM` over WinRM on the Hyper-V host and adds the virtual machines to the device inventory.

## Use cases

* List the virtual machines on your Hyper-V hosts.

```
Adapters = microsoft-hyper-v
```

## Before you begin

### Network

| Source              | Destination          | Port                        | Protocol      |
| ------------------- | -------------------- | --------------------------- | ------------- |
| OctoXLabs connector | Hyper-V host (WinRM) | 5985 (HTTP) or 5986 (HTTPS) | HTTP or HTTPS |

### Required permissions

| Scope or role                                                       | Permission | Needed for       |
| ------------------------------------------------------------------- | ---------- | ---------------- |
| Account allowed to open remote PowerShell sessions and run `Get-VM` | Read       | Virtual machines |

The frontend instructions do not list a role. Not verified which Hyper-V role or group is needed.

## Create credentials in Microsoft Hyper V

{% stepper %}
{% step %}

### Enable WinRM

Enable the WinRM listener on the Hyper-V host (port 5985 for HTTP, 5986 for HTTPS).
{% endstep %}

{% step %}

### Create an account

Use an account that can open remote PowerShell sessions on the host and read VMs.
{% endstep %}

{% step %}

### Choose the auth type

NTLM is the default. For Kerberos, use a UPN username or set the Kerberos realm and KDC IP.
{% endstep %}
{% endstepper %}

## Connection parameters

| Parameter                                | Required | Type    | Default | Description                                                                                |
| ---------------------------------------- | -------- | ------- | ------- | ------------------------------------------------------------------------------------------ |
| IP (`ip`)                                | Yes      | String  |         | IP address or hostname of the Windows host.                                                |
| Port (`port`)                            | No       | Integer | 5985    | WinRM port. 5985 is the HTTP listener, 5986 the HTTPS listener.                            |
| Username (`username`)                    | Yes      | String  |         | Account used to connect. For Kerberos, use UPN format (`user@CONTOSO.COM`).                |
| Password (`password`)                    | Yes      | String  |         | Password of the account.                                                                   |
| Is Secure (`is_secure`)                  | No       | Boolean | False   | Connect over HTTPS. Use it with port 5986.                                                 |
| Auth Type (`auth_type`)                  | No       | String  | NTLM    | One of Basic, Certificate, NTLM, Kerberos, Plaintext, SSL, Credssp.                        |
| Certificate verification (`cert_verify`) | No       | Boolean | True    | Validate the WinRM HTTPS certificate. Applied only when Is Secure is on.                   |
| Kerberos realm (`kerberos_realm`)        | No       | String  |         | Realm in uppercase. Needed when Auth Type is Kerberos and the username is not in UPN form. |
| KDC IP / FQDN (`kdc_ip`)                 | No       | String  |         | Kerberos KDC host. Leave empty to use DNS discovery.                                       |

## Troubleshooting

| Error message                | Cause                                                                   | Fix                                                                                                                   |
| ---------------------------- | ----------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------- |
| Connection test failed.      | Neither the HTTP nor the HTTPS WinRM session ran `whoami` successfully. | Check the port, Is Secure, Auth Type and the account. The account must be allowed to open remote PowerShell sessions. |
| Failed to parse JSON output: | The `Get-VM` output could not be read as JSON.                          | Check the output of \`Get-VM                                                                                          |

## Change history

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