Select first adapter attached to host OS's switch

If more than one vNic is attached to vmSwitch, use the first one only.
This commit is contained in:
Vladimír 2019-10-15 15:14:22 +02:00 committed by GitHub
parent 6a85855c81
commit d6994df188
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 1 deletions

View File

@ -32,7 +32,7 @@ type scriptOptions struct {
func GetHostAdapterIpAddressForSwitch(switchName string) (string, error) {
var script = `
param([string]$switchName, [int]$addressIndex)
$HostVMAdapter = Hyper-V\Get-VMNetworkAdapter -ManagementOS -SwitchName $switchName
$HostVMAdapter = Hyper-V\Get-VMNetworkAdapter -ManagementOS -SwitchName $switchName | Select-Object -First 1
if ($HostVMAdapter){
$HostNetAdapter = Get-NetAdapter | Where-Object { $_.DeviceId -eq $HostVMAdapter.DeviceId }
if ($HostNetAdapter){