<# .SYNOPSIS Standalone debug script — inspect the raw VMkernel service-tagging data on a live vCenter, independent of Switchblade-Collector's own parsing logic (Get-HostServiceMap in Switchblade-Collector.ps1). .DESCRIPTION Prints, for one host: - every virtualNicManagerInfo.NetConfig entry: NicType + raw SelectedVnic string values - every config.network.Vnic entry: Device + Key - the software iSCSI HBA (if any) and its QueryBoundVnics() result Compare the raw SelectedVnic strings against the vnic Key strings by eye — Get-HostServiceMap assumes SelectedVnic entries look like "{NicType}.{vnic.Key}" (e.g. "management.key-vim.host.VirtualNic-vmk0") and strips that prefix to resolve the device name. If this vCenter's SelectedVnic strings are shaped differently, that's exactly what would cause zero VMkernel services to ever be detected — this script tells us what shape to fix the parsing to instead of guessing. .PARAMETER HostName Name of the host to inspect (as PowerCLI/vCenter knows it). Defaults to the first host found if omitted. .EXAMPLE Connect-VIServer vcenter.example.com -Credential (Get-Credential) ./Debug-VnicServices.ps1 -HostName esx01.example.com #> [CmdletBinding()] param( [string]$HostName ) if (-not $global:DefaultVIServer -or -not $global:DefaultVIServer.IsConnected) { throw "Not connected to a vCenter/ESXi host. Run Connect-VIServer first." } $hostViews = @(Get-View -ViewType HostSystem) if ($hostViews.Count -eq 0) { throw "No hosts found." } $hostView = if ($HostName) { $hostViews | Where-Object { $_.Name -eq $HostName } | Select-Object -First 1 } else { $hostViews[0] } if (-not $hostView) { throw "Host '$HostName' not found. Available hosts: $($hostViews.Name -join ', ')" } Write-Host "=== Host: $($hostView.Name) ===" -ForegroundColor Cyan Write-Host "`n--- config.virtualNicManagerInfo.netConfig ---" -ForegroundColor Yellow $netConfigs = $hostView.Config.VirtualNicManagerInfo.NetConfig if (-not $netConfigs -or $netConfigs.Count -eq 0) { Write-Host "(empty or null — this alone would explain zero VMkernel services detected)" -ForegroundColor Red } else { foreach ($cfg in $netConfigs) { Write-Host "NicType: $($cfg.NicType)" Write-Host " SelectedVnic: $($cfg.SelectedVnic -join ', ')" } } Write-Host "`n--- config.network.vnic (device + key) ---" -ForegroundColor Yellow $vnics = $hostView.Config.Network.Vnic if (-not $vnics -or $vnics.Count -eq 0) { Write-Host "(empty or null)" -ForegroundColor Red } else { foreach ($v in $vnics) { Write-Host "Device: $($v.Device) Key: $($v.Key) Portgroup: $($v.Spec.Portgroup)" } } Write-Host "`n--- software iSCSI HBA + QueryBoundVnics ---" -ForegroundColor Yellow try { $storageSystem = Get-View $hostView.ConfigManager.StorageSystem -ErrorAction Stop $hbas = $hostView.Config.StorageDevice.HostBusAdapter $iscsiHbas = @($hbas | Where-Object { $_.Driver -eq "iscsi_vmk" }) if ($iscsiHbas.Count -eq 0) { Write-Host "(no software iSCSI HBA on this host)" } else { foreach ($hba in $iscsiHbas) { Write-Host "HBA device: $($hba.Device)" $bound = $storageSystem.QueryBoundVnics($hba.Device) foreach ($b in $bound) { Write-Host " Bound vnic: $($b.VnicDevice)" } } } } catch { Write-Host "Error querying iSCSI binding: $_" -ForegroundColor Red } Write-Host "`n--- What Get-HostServiceMap would actually resolve ---" -ForegroundColor Yellow $keyToDevice = @{} foreach ($v in $vnics) { $keyToDevice[$v.Key] = $v.Device } $anyResolved = $false foreach ($cfg in $netConfigs) { $prefix = "$($cfg.NicType)." foreach ($selected in $cfg.SelectedVnic) { $vnicKey = if ($selected.StartsWith($prefix)) { $selected.Substring($prefix.Length) } else { $selected } $device = $keyToDevice[$vnicKey] if ($device) { Write-Host " $($cfg.NicType) -> $device (resolved OK)" -ForegroundColor Green $anyResolved = $true } else { Write-Host " $($cfg.NicType) -> UNRESOLVED (tried key '$vnicKey' from selected value '$selected')" -ForegroundColor Red } } } if (-not $anyResolved) { Write-Host "`nNothing resolved. Compare the raw SelectedVnic strings above against the raw Key strings above by eye to see the actual shape mismatch." -ForegroundColor Red }