From 96603f025a173423af0a73b2e96dc07a67c0c30b Mon Sep 17 00:00:00 2001 From: rbalsleyMSFT <53497092+rbalsleyMSFT@users.noreply.github.com> Date: Tue, 3 Mar 2026 18:22:32 -0800 Subject: [PATCH] Includes disk size in VHDX cache validation Prevents reusing cached images when the requested disk size changes. Ensures the disk size property is properly saved and verified against existing cache items to maintain configuration accuracy. --- FFUDevelopment/BuildFFUVM.ps1 | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/FFUDevelopment/BuildFFUVM.ps1 b/FFUDevelopment/BuildFFUVM.ps1 index b483dd3..6bee045 100644 --- a/FFUDevelopment/BuildFFUVM.ps1 +++ b/FFUDevelopment/BuildFFUVM.ps1 @@ -580,6 +580,7 @@ class VhdxCacheUpdateItem { class VhdxCacheItem { [string]$VhdxFileName = "" [uint32]$LogicalSectorSizeBytes = "" + [uint64]$Disksize = "" [string]$WindowsSKU = "" [string]$WindowsRelease = "" [string]$WindowsVersion = "" @@ -6418,6 +6419,10 @@ try { if ($vhdxCacheItem.WindowsRelease -ne $WindowsRelease) { WriteLog 'WindowsRelease mismatch, continuing'; continue } if ($vhdxCacheItem.WindowsVersion -ne $WindowsVersion) { WriteLog 'WindowsVersion mismatch, continuing'; continue } if ($vhdxCacheItem.OptionalFeatures -ne $OptionalFeatures) { WriteLog 'OptionalFeatures mismatch, continuing'; continue } + if ($vhdxCacheItem.PSObject.Properties.Name -notcontains 'Disksize') { WriteLog 'Disksize missing in cached config, continuing'; continue } + [uint64]$cachedDisksize = 0 + if (-not [uint64]::TryParse([string]$vhdxCacheItem.Disksize, [ref]$cachedDisksize)) { WriteLog "Disksize invalid in cached config ($($vhdxCacheItem.Disksize)), continuing"; continue } + if ($cachedDisksize -ne $Disksize) { WriteLog "Disksize mismatch (cached: $cachedDisksize, current: $Disksize), continuing"; continue } $cachedUpdateNames = @() if ($vhdxCacheItem.IncludedUpdates -and $vhdxCacheItem.IncludedUpdates.Count -gt 0) { @@ -6885,6 +6890,7 @@ try { } $cachedVHDXInfo.VhdxFileName = $("$VMName.vhdx") $cachedVHDXInfo.LogicalSectorSizeBytes = $LogicalSectorSizeBytes + $cachedVHDXInfo.Disksize = $Disksize $cachedVHDXInfo.WindowsSKU = $WindowsSKU $cachedVHDXInfo.WindowsRelease = $WindowsRelease $cachedVHDXInfo.WindowsVersion = $WindowsVersion