Get HP Driver Pack Info with PowerShell – Web Scraping Method

So I was preparing an OSD task sequence in ConfigMgr to deploy Windows 10 1909 and I wanted to know if any of the HP workstations I would be deploying to had updated driver packs available for 1909, since I had simply copied the task sequence used for 1903.

A while ago I posted a blog with a script to download the latest driver packs from Dell using a web-scraping method, so I decided to take a similar approach for HP driver packs. HP publish a list of the driver packs available for various models and OS versions on the web in a tabular format, so I decided to try to convert that HTML table into data that could also be displayed in table format in PowerShell as well as being queryable, and the script below is the result.

$Architecture = "64-bit"
# Load the HP driver pack web page
If ($Architecture -eq "64-bit")
$URI = ""
If ($Architecture -eq "32-bit")
$URI = ""
$HTML = Invoke-WebRequest Uri $URI ErrorAction Stop
# Scrape the table rows and headers for the datatable
$TableRows = $HTML.AllElements | where {$_.tagName -eq "TR"-and $_.innerHTML -match "<P>"}
$Headers = ($HTML.AllElements | where {$_.tagName -eq "TR" -and $_.innerHTML -match "Windows 10"})[0].innerHTML
[string]$ColumnExpression = "<td[^>]*>(.*?)</td>"
$HeaderMatches = [Regex]::Matches($Headers, $ColumnExpression, ([System.Text.RegularExpressions.RegexOptions]::Multiline, [System.Text.RegularExpressions.RegexOptions]::Singleline, [System.Text.RegularExpressions.RegexOptions]::IgnoreCase))
# Load the headers as columns into a datatable
$DataTable = New-Object System.Data.DataTable
foreach ($Match in ($HeaderMatches | Select Skip 1))
foreach ($Table in $TableRows)
[string]$ColumnExpression = "<td[^>]*>(.*?)</td>"
$Matches = [Regex]::Matches($Table.innerHTML, $ColumnExpression, ([System.Text.RegularExpressions.RegexOptions]::Multiline, [System.Text.RegularExpressions.RegexOptions]::Singleline, [System.Text.RegularExpressions.RegexOptions]::IgnoreCase))
$array = New-Object System.Collections.ArrayList
# Process each regex match (table data entry)
foreach ($Item in $Matches)
# Add the models
If ($Item.Index -eq 0)
[array]$Models = ($Item.Value.Split('>') | where {$_ -match "/p"}).Replace("</P","")
foreach ($Model in $Models)
[string]$ModelString = $ModelString + "$Model, "
$ModelString = $ModelString.TrimEnd(', ')
Remove-Variable Name ModelString Force
# Add the driver pack url and version
If ($Item.Value -notmatch "<P>")
$Value = ""
$href = $Item.Value.Split() | Where {$_ -match "href"} | Where {$_ -match "exe"}
$Link = $href.Split('>')[0].Replace('href="','').TrimEnd('"')
$Version = ($Item.Value.Split('=') | where {$_ -match "Version"}).Replace('"','').TrimEnd(' href')
$Value = "$Link ($Version)"
# Add an entry to the datatable
If ($Architecture -eq '64-bit')
If ($Architecture -eq '32-bit')
Return $DataTable

This kind of data displays well in PowerShell’s gridview, like so:

Get-HPDriverPacks | Out-GridView 

In the first column you find the models and the next columns contain the driver pack version, release date and download URL for the various OS versions. You can then use the gridview’s native filtering capabilities to find something specific:

By default, the script will get the 64-bit driver packs, but you can also get 32-bit for Windows 7 etc (you’re not still using Windows 7 are you?!):

Get-HPDriverPacks -Architecture '32-bit'

I can also query the data within PowerShell directly, for example:

$DPs = Get-HPDriverPacks
$DPs | where {$_.Model -match "1040"} | Select Model,"Windows 10 64-bit, 1909"

To find out which models had driver packs for Windows 10 1909 that have been updated since the 1903 version, I did the following:

$DPs | 
    Where {$_."Windows 10 64-bit, 1909" -ne "-" -and $_."Windows 10 64-bit, 1909" -ne $_."Windows 10 64-bit, 1903"} | 
    Select Model,"Windows 10 64-bit, 1909" |

So those are the models whose driver packs I can update in the 1909 OSD task sequence.

You can also download the driver packs from this data too, eg:

$URL = ($DPs | where {$_.Model -match "1040 G6"} | Select -ExpandProperty "Windows 10 64-bit, 1909").Split()[0]
Invoke-WebRequest -Uri $URL -OutFile "C:\temp\$($url.Split('/') | Select -Last 1)"

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.