From fc4a71f7e1ff8cd4ca5b135987c5ee721c4ded05 Mon Sep 17 00:00:00 2001 From: rbalsleyMSFT <53497092+rbalsleyMSFT@users.noreply.github.com> Date: Tue, 18 Nov 2025 20:03:22 -0800 Subject: [PATCH] Restricts manufacturer folder detection to known OEMs Improves driver folder discovery logic by explicitly defining recognized manufacturer folder names (Dell, HP, Lenovo, Microsoft) instead of treating any root-level folder with children as a manufacturer folder. Prevents incorrect categorization of non-manufacturer folders at the root level and ensures only legitimate OEM folders are processed for model-specific driver packages. Refactors control flow to eliminate else block, improving code clarity and maintainability. --- .../WinPEDeployFFUFiles/ApplyFFU.ps1 | 32 +++++++++++-------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/FFUDevelopment/WinPEDeployFFUFiles/ApplyFFU.ps1 b/FFUDevelopment/WinPEDeployFFUFiles/ApplyFFU.ps1 index bc929e6..2aa66ae 100644 --- a/FFUDevelopment/WinPEDeployFFUFiles/ApplyFFU.ps1 +++ b/FFUDevelopment/WinPEDeployFFUFiles/ApplyFFU.ps1 @@ -1155,6 +1155,7 @@ if ($null -eq $DriverSourcePath) { # Build folder list that surfaces Manufacturer\Model entries $DriverFolders = Get-ChildItem -Path $DriversPath -Directory $driversRootFullPath = (Get-Item -Path $DriversPath).FullName.TrimEnd('\') + $manufacturerFolderNames = @('dell','hp','lenovo','microsoft') $relativePathResolver = { param( [string]$candidatePath, @@ -1187,8 +1188,13 @@ if ($null -eq $DriverSourcePath) { } } foreach ($driverFolder in $DriverFolders) { - $childModelFolders = Get-ChildItem -Path $driverFolder.FullName -Directory -ErrorAction SilentlyContinue - if (($childModelFolders.Count -gt 0) -and ($driverFolder.Parent.FullName -eq $driversRootFullPath)) { + $parentIsRoot = $driverFolder.Parent.FullName -eq $driversRootFullPath + $folderNameLower = $driverFolder.Name.ToLowerInvariant() + $isManufacturerFolder = $parentIsRoot -and ($manufacturerFolderNames -contains $folderNameLower) + + if ($isManufacturerFolder) { + # Only manufacturer folders (Dell/HP/Lenovo/Microsoft) should surface child model folders. + $childModelFolders = Get-ChildItem -Path $driverFolder.FullName -Directory -ErrorAction SilentlyContinue foreach ($modelFolder in $childModelFolders) { if (-not (Test-DriverFolderHasInstallableContent -Path $modelFolder.FullName)) { WriteLog "Skipping driver folder '$($modelFolder.FullName)' because no installable files were found." @@ -1201,18 +1207,18 @@ if ($null -eq $DriverSourcePath) { RelativePath = $relativePath } } + continue } - else { - if (-not (Test-DriverFolderHasInstallableContent -Path $driverFolder.FullName)) { - WriteLog "Skipping driver folder '$($driverFolder.FullName)' because no installable files were found." - continue - } - $relativePath = & $relativePathResolver -candidatePath $driverFolder.FullName -rootPath $driversRootFullPath - $DriverSources += [PSCustomObject]@{ - Type = 'Folder' - Path = $driverFolder.FullName - RelativePath = $relativePath - } + + if (-not (Test-DriverFolderHasInstallableContent -Path $driverFolder.FullName)) { + WriteLog "Skipping driver folder '$($driverFolder.FullName)' because no installable files were found." + continue + } + $relativePath = & $relativePathResolver -candidatePath $driverFolder.FullName -rootPath $driversRootFullPath + $DriverSources += [PSCustomObject]@{ + Type = 'Folder' + Path = $driverFolder.FullName + RelativePath = $relativePath } }