Merge pull request #12472 from chrisroberts/hyperv-net

Use detected device when iterating over available addresses
This commit is contained in:
Chris Roberts 2021-07-27 08:18:17 -07:00 committed by GitHub
commit 868c5fc633
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -18,7 +18,7 @@ try {
$netdev = Hyper-V\Get-VMNetworkAdapter -VM $vm | Select-Object -Index 0
if ($netdev -ne $null) {
if ($netdev.IpAddresses.Length -gt 0) {
foreach ($ip_address in $network.IpAddresses) {
foreach ($ip_address in $netdev.IpAddresses) {
if ($ip_address.Contains(".") -And [string]::IsNullOrEmpty($ip4_address)) {
$ip4_address = $ip_address
} elseif ($ip_address.Contains(":") -And [string]::IsNullOrEmpty($ip6_address)) {