From 6e5d634af65796aad3ec7dbfcd99103184d41bc5 Mon Sep 17 00:00:00 2001 From: JonasKloseBW Date: Fri, 27 Sep 2024 02:15:25 +0200 Subject: [PATCH] Update BuildFFUVM.ps1 - Bypass VMSwitchIPAddress to VMHostAddress check on systems with a configured NAT setup --- FFUDevelopment/BuildFFUVM.ps1 | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/FFUDevelopment/BuildFFUVM.ps1 b/FFUDevelopment/BuildFFUVM.ps1 index dadc8cf..2e6e681 100644 --- a/FFUDevelopment/BuildFFUVM.ps1 +++ b/FFUDevelopment/BuildFFUVM.ps1 @@ -3805,7 +3805,19 @@ if (($VMHostIPAddress) -and ($VMSwitchName)){ throw "IP address for -VMSwitchName $VMSwitchName not found. Please check the -VMSwitchName parameter and try again." } if ($VMSwitchIPAddress -ne $VMHostIPAddress) { - throw "IP address for -VMSwitchName $VMSwitchName is $VMSwitchIPAddress, which does not match the -VMHostIPAddress $VMHostIPAddress. Please check the -VMHostIPAddress parameter and try again." + try { + # Bypass the check for systems that could have a Hyper-V NAT switch + $null = Get-NetNat -ErrorAction Stop + $NetNat = @(Get-NetNat -ErrorAction Stop); + } catch { + throw "IP address for -VMSwitchName $VMSwitchName is $VMSwitchIPAddress, which does not match the -VMHostIPAddress $VMHostIPAddress. Please check the -VMHostIPAddress parameter and try again." + } + if ($NetNat.Count -gt 0) { + WriteLog "IP address for -VMSwitchName $VMSwitchName is $VMSwitchIPAddress, which does not match the -VMHostIPAddress $VMHostIPAddress!" + WriteLog "NAT setup detected, remember to configure NATing if the FFU image can't be captured to the network share on the host." + } else { + throw "IP address for -VMSwitchName $VMSwitchName is $VMSwitchIPAddress, which does not match the -VMHostIPAddress $VMHostIPAddress. Please check the -VMHostIPAddress parameter and try again." + } } WriteLog '-VMSwitchName and -VMHostIPAddress validation complete' }