Werk #19577: hyperv_host: Fix empty vhd, vsan, nic and integration service counts for single-item VMs
| Component | Checks & agents | ||||
| Title | hyperv_host: Fix empty vhd, vsan, nic and integration service counts for single-item VMs | ||||
| Date | Jul 9, 2026 | ||||
| Level | Trivial Change | ||||
| Class | Bug Fix | ||||
| Compatibility | Compatible - no manual interaction needed | ||||
| Checkmk versions & editions |
|
The Windows Hyper-V host agent plugin (hyperv_host.ps1) reports, for each
virtual machine, the number of virtual hard disks, virtual SANs, network
adapters, integration services and VM group memberships. When a virtual machine
had exactly one of these items, the reported count was empty instead of 1.
The agent executes plugins with Windows PowerShell 5.1. Unlike PowerShell 7, it
does not expose a .Count property on a scalar value, and a cmdlet such as
Get-VMHardDiskDrive returns a bare object rather than a collection when only a
single item exists. The affected output lines therefore emitted no number.
The collections are now wrapped in an array subexpression, so a correct count is produced for single-item and multi-item virtual machines alike, on both PowerShell versions.