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 pnp. Just download the drivers to
16- $env:TEMP and exit.
1714. PARAMETER Model
1815 The literal regex string that matches a URL on the Manufacturer's website
1916 pointing to the exact download URL of the driver.
17+ . PARAMETER SkipDownload
18+ [OPTIONAL] Don't download drivers from the Manufacturer website. Just execute
19+ drivers that were previously downloaded.
20+ . PARAMETER SkipInstall
21+ [OPTIONAL] Don't install drivers via pnp. Just download the drivers to
22+ $env:TEMP and exit.
2023. EXAMPLE
2124 .\install_drivers.ps1 -Manufacturer Lenovo -Model 20y0
2225
@@ -42,7 +45,9 @@ param (
4245 [Parameter (Mandatory )]
4346 [string ]$Model ,
4447 [Parameter ()]
45- [switch ]$DownloadOnly
48+ [switch ]$SkipDownload ,
49+ [Parameter ()]
50+ [switch ]$SkipInstall
4651)
4752
4853function Get-RegexMatch {
@@ -58,12 +63,12 @@ function Get-RegexMatch {
5863 # file_regex was manually tested against multiple models
5964 # match_index is required if we have multiple regex groups
6065 switch ($Manufacturer ) {
61- ' Lenovo ' {
66+ ' LENOVO ' {
6267 $manufacturer_uri = ' https://download.lenovo.com/cdrt/td/catalogv2.xml'
6368 $file_regex = " https.*?$Model .*?exe"
6469 $match_index = 0
6570 }
66- ' Dell ' {
71+ ' DELL ' {
6772 $manufacturer_uri = ' https://www.dell.com/support/kbdoc/en-uk/000180534/dell-family-driver-packs'
6873 $file_regex = " (?:$Model .*?[\s\S]*?)(https.*?zip)"
6974 $match_index = 1
@@ -192,22 +197,25 @@ try {
192197 New-Item - ItemType Directory $TEMP_PATH - Force | Out-Null
193198 }
194199
195- $regex_uri , $file_name = Get-RegexMatch - Manufacturer $Manufacturer - Model $Model
196- $installer = " $TEMP_PATH \$file_name "
200+ if (-not $SkipDownload ) {
201+ $regex_uri , $file_name = Get-RegexMatch - Manufacturer $Manufacturer - Model $Model
202+ $installer = " $TEMP_PATH \$file_name "
197203
198- Get-Installer - DownloadURI $regex_uri - InstallerName $installer
204+ Get-Installer - DownloadURI $regex_uri - InstallerName $installer
199205
200- Expand-Installer - Manufacturer $Manufacturer - InstallerName $installer - Destination $TEMP_PATH
206+ Expand-Installer - Manufacturer $Manufacturer - InstallerName $installer - Destination $TEMP_PATH
207+ }
201208
202- if (-not $DownloadOnly ) {
209+ if (-not $SkipInstall ) {
203210 Install-Drivers - Destination $TEMP_PATH
204211 }
205212} catch {
206213 throw $_
207214} finally {
208- if (-not $DownloadOnly ) {
215+ if (-not $SkipInstall ) {
209216 Remove-Item $TEMP_PATH - Force - Recurse - ErrorAction Continue
210217 Remove-Item - Path " HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\UnattendSettings\PnPUnattend\DriverPaths\1" - Recurse - Force
211218 }
219+
212220 $ProgressPreference = $OldProgressPreference
213221}
0 commit comments