From 2273cffbc2fca65236b644464faeabdf82e7db20 Mon Sep 17 00:00:00 2001 From: rbalsleyMSFT <53497092+rbalsleyMSFT@users.noreply.github.com> Date: Sat, 29 Nov 2025 13:57:54 -0800 Subject: [PATCH] Add Threads parameter to control parallel driver download throttling Introduces a new `Threads` parameter that allows users to configure the concurrency level for parallel driver downloads within the script. This parameter defaults to 5, matching the existing UI behavior, and accepts values between 1 and 64 to provide flexible control over resource utilization. The parameter is now passed to the parallel processing function via the `ThrottleLimit` argument, enabling users to optimize performance based on their system capabilities and network conditions. --- FFUDevelopment/BuildFFUVM.ps1 | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/FFUDevelopment/BuildFFUVM.ps1 b/FFUDevelopment/BuildFFUVM.ps1 index ebf30f2..f353c0f 100644 --- a/FFUDevelopment/BuildFFUVM.ps1 +++ b/FFUDevelopment/BuildFFUVM.ps1 @@ -202,6 +202,9 @@ Example: @{ "SanDisk Ultra" = "1234567890"; "Kingston DataTraveler" = "098765432 .PARAMETER MaxUSBDrives Maximum number of USB drives to build in parallel. Default is 5. Set to 0 to process all discovered drives (or all selected drives when USBDriveList or selection is used). Actual throttle will never exceed the number of drives discovered. +.PARAMETER Threads +Controls the throttle applied to parallel tasks inside the script. Default is 5, matching the UI Threads field, and applies to driver downloads invoked through Invoke-ParallelProcessing. + .PARAMETER UserAgent User agent string to use when downloading files. @@ -354,6 +357,8 @@ param( [bool]$BuildUSBDrive, [hashtable]$USBDriveList, [int]$MaxUSBDrives = 5, + [ValidateRange(1, 64)] + [int]$Threads = 5, [ValidateSet('Foreground', 'High', 'Normal', 'Low')] [string]$BitsPriority = 'Normal', [Parameter(Mandatory = $false)] @@ -5040,13 +5045,15 @@ if ($driversJsonPath -and (Test-Path $driversJsonPath) -and ($InstallDrivers -or } WriteLog "Starting parallel driver processing using Invoke-ParallelProcessing..." + # Use the configured Threads value to control driver download concurrency $parallelResults = Invoke-ParallelProcessing -ItemsToProcess $driversToProcess ` -TaskType 'DownloadDriverByMake' ` -TaskArguments $taskArguments ` -IdentifierProperty 'Model' ` -WindowObject $null ` -ListViewControl $null ` - -MainThreadLogPath $LogFile + -MainThreadLogPath $LogFile ` + -ThrottleLimit $Threads # After processing, update the driver mapping file and detect failures $successfullyDownloaded = [System.Collections.Generic.List[PSCustomObject]]::new()