Skip to content

Commit 8caf80e

Browse files
committed
feat: Add optional DownloadOnly parameter
1 parent 8d96635 commit 8caf80e

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

Install-ModelDrivers/install_model_drivers.ps1

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111
display, etc. drivers.
1212
.PARAMETER Manufacturer
1313
The Manufacturer of the device. Must be one of 'Lenovo', 'Dell', 'HP'.
14+
.PARAMETER DownloadOnly
15+
[OPTIONAL] Don't install drivers via pnputil. Just download the drivers to
16+
$env:TEMP and exit.
1417
.PARAMETER Model
1518
The literal regex string that matches a URL on the Manufacturer's website
1619
pointing to the exact download URL of the driver.
@@ -36,7 +39,9 @@ param (
3639
[Parameter(Mandatory)]
3740
[string]$Manufacturer,
3841
[Parameter(Mandatory)]
39-
[string]$Model
42+
[string]$Model,
43+
[Parameter()]
44+
[switch]$DownloadOnly
4045
)
4146

4247
function Get-RegexMatch {
@@ -191,10 +196,14 @@ try {
191196

192197
Expand-Installer -Manufacturer $Manufacturer -InstallerName $installer -Destination $TEMP_PATH
193198

194-
Install-Drivers -Destination $TEMP_PATH
199+
if (-not $DownloadOnly) {
200+
Install-Drivers -Destination $TEMP_PATH
201+
}
195202
} catch {
196203
throw $_
197204
} finally {
198-
Remove-Item $TEMP_PATH -Force -Recurse -ErrorAction Continue
205+
if (-not $DownloadOnly) {
206+
Remove-Item $TEMP_PATH -Force -Recurse -ErrorAction Continue
207+
}
199208
$ProgressPreference = $OldProgressPreference
200209
}

0 commit comments

Comments
 (0)