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.
This commit is contained in:
rbalsleyMSFT
2025-11-29 13:57:54 -08:00
parent 63ef35a005
commit 2273cffbc2
+8 -1
View File
@@ -202,6 +202,9 @@ Example: @{ "SanDisk Ultra" = "1234567890"; "Kingston DataTraveler" = "098765432
.PARAMETER MaxUSBDrives .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. 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 .PARAMETER UserAgent
User agent string to use when downloading files. User agent string to use when downloading files.
@@ -354,6 +357,8 @@ param(
[bool]$BuildUSBDrive, [bool]$BuildUSBDrive,
[hashtable]$USBDriveList, [hashtable]$USBDriveList,
[int]$MaxUSBDrives = 5, [int]$MaxUSBDrives = 5,
[ValidateRange(1, 64)]
[int]$Threads = 5,
[ValidateSet('Foreground', 'High', 'Normal', 'Low')] [ValidateSet('Foreground', 'High', 'Normal', 'Low')]
[string]$BitsPriority = 'Normal', [string]$BitsPriority = 'Normal',
[Parameter(Mandatory = $false)] [Parameter(Mandatory = $false)]
@@ -5040,13 +5045,15 @@ if ($driversJsonPath -and (Test-Path $driversJsonPath) -and ($InstallDrivers -or
} }
WriteLog "Starting parallel driver processing using Invoke-ParallelProcessing..." WriteLog "Starting parallel driver processing using Invoke-ParallelProcessing..."
# Use the configured Threads value to control driver download concurrency
$parallelResults = Invoke-ParallelProcessing -ItemsToProcess $driversToProcess ` $parallelResults = Invoke-ParallelProcessing -ItemsToProcess $driversToProcess `
-TaskType 'DownloadDriverByMake' ` -TaskType 'DownloadDriverByMake' `
-TaskArguments $taskArguments ` -TaskArguments $taskArguments `
-IdentifierProperty 'Model' ` -IdentifierProperty 'Model' `
-WindowObject $null ` -WindowObject $null `
-ListViewControl $null ` -ListViewControl $null `
-MainThreadLogPath $LogFile -MainThreadLogPath $LogFile `
-ThrottleLimit $Threads
# After processing, update the driver mapping file and detect failures # After processing, update the driver mapping file and detect failures
$successfullyDownloaded = [System.Collections.Generic.List[PSCustomObject]]::new() $successfullyDownloaded = [System.Collections.Generic.List[PSCustomObject]]::new()