From 902a9b13aa69e3986b45a51aa82984d67067a5fe Mon Sep 17 00:00:00 2001 From: BobSilent Date: Wed, 3 Apr 2019 17:36:32 +0200 Subject: [PATCH] Update hyperv.go maybe also a fix for issue #5023 at least I got same error like there, incl. VM response ==> hyperv-iso: Host IP for the HyperV machine: False although #4947 is marked as duplicate but shows different error output ==> hyperv-iso: Error getting host adapter ip address: PowerShell error: Get-VMNetworkAdapter : No network adapter is found with the given input. --- common/powershell/hyperv/hyperv.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/common/powershell/hyperv/hyperv.go b/common/powershell/hyperv/hyperv.go index fbdba92c4a1..e2a3eab0a1b 100644 --- a/common/powershell/hyperv/hyperv.go +++ b/common/powershell/hyperv/hyperv.go @@ -35,9 +35,9 @@ param([string]$switchName, [int]$addressIndex) $HostVMAdapter = Hyper-V\Get-VMNetworkAdapter -ManagementOS -SwitchName $switchName if ($HostVMAdapter){ - $HostNetAdapter = Get-NetAdapter | ?{ $_.DeviceID -eq $HostVMAdapter.DeviceId } + $HostNetAdapter = Get-NetAdapter | ?{ $HostVMAdapter.DeviceId.Contains($_.DeviceID) } if ($HostNetAdapter){ - $HostNetAdapterConfiguration = @(get-wmiobject win32_networkadapterconfiguration -filter "IPEnabled = 'TRUE' AND InterfaceIndex=$($HostNetAdapter.ifIndex)") + $HostNetAdapterConfiguration = @(get-wmiobject win32_networkadapterconfiguration -filter "IPEnabled = 'TRUE'") | Where-Object { $HostNetAdapter.ifIndex.Contains($_.InterfaceIndex) } if ($HostNetAdapterConfiguration){ return @($HostNetAdapterConfiguration.IpAddress)[$addressIndex] }