Skip to content

Commit

Permalink
Update hyperv.go
Browse files Browse the repository at this point in the history
maybe also a fix for issue hashicorp#5023
at least I got same error like there, incl. VM response
==> hyperv-iso: Host IP for the HyperV machine: False

although hashicorp#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.
  • Loading branch information
BobSilent authored Apr 3, 2019
1 parent e4842b6 commit 902a9b1
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions common/powershell/hyperv/hyperv.go
Original file line number Diff line number Diff line change
Expand Up @@ -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]
}
Expand Down

0 comments on commit 902a9b1

Please sign in to comment.