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.
This commit is contained in:
BobSilent 2019-04-03 17:36:32 +02:00 committed by Andre Mainka
parent e4842b69b4
commit 5b289f67fe
1 changed files with 4 additions and 2 deletions

View File

@ -35,9 +35,11 @@ param([string]$switchName, [int]$addressIndex)
$HostVMAdapter = Hyper-V\Get-VMNetworkAdapter -ManagementOS -SwitchName $switchName $HostVMAdapter = Hyper-V\Get-VMNetworkAdapter -ManagementOS -SwitchName $switchName
if ($HostVMAdapter){ if ($HostVMAdapter){
$HostNetAdapter = Get-NetAdapter | ?{ $_.DeviceID -eq $HostVMAdapter.DeviceId } $HostNetAdapter = Get-NetAdapter | ?{ $HostVMAdapter.DeviceId.Contains($_.DeviceID) }
if ($HostNetAdapter){ if ($HostNetAdapter){
$HostNetAdapterConfiguration = @(get-wmiobject win32_networkadapterconfiguration -filter "IPEnabled = 'TRUE' AND InterfaceIndex=$($HostNetAdapter.ifIndex)") $HostNetAdapterIfIndex = @()
$HostNetAdapterIfIndex += $HostNetAdapter.ifIndex
$HostNetAdapterConfiguration = @(get-wmiobject win32_networkadapterconfiguration -filter "IPEnabled = 'TRUE'") | Where-Object { $HostNetAdapterIfIndex.Contains($_.InterfaceIndex) }
if ($HostNetAdapterConfiguration){ if ($HostNetAdapterConfiguration){
return @($HostNetAdapterConfiguration.IpAddress)[$addressIndex] return @($HostNetAdapterConfiguration.IpAddress)[$addressIndex]
} }