Create a Powershell script to automatically lookup and download HP printer firmware files

Bastiaan Oosterman 21 Reputation points


I want to create a Powershell script that I can run periodically to automatically download the latest HP printer firmware files.

The source where I can find the path to the latest firmware file for each printer model is this URL:

One item for example:

[HP LaserJet 600 M601/M602/M603]
SupportedModels = HP LaserJet M601n; HP LaserJet M601dn;HP LaserJet M602n; HP LaserJet M602dn; HP LaserJet M602x; HP LaserJet 600 M602;HP LaserJet M603n; HP LaserJet M603dn; HP LaserJet M603xh; HP LaserJet 600 M602; HP LaserJet 600 M603; HP LaserJet 600 M601;
Path =
Name = ljM601_602_603_fs3.9.9_2309059_000599.bdl
Size = 86072636
Version = 2309059_000599 (FutureSmart Bundle Version 3.9.9)
Revision = 2309059_000599
Date = 20220214
Asset Identifier = 736664-0015

I would like the script to download the firmware of some printer models that I can specify beforehand, so I don't need all the firmware files.

Unfortunately I don't have much knowledge of how to create Powershell script, so I hope someone has an example for me similar to this that I can reuse.

Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,449 questions
0 comments No comments
{count} votes

Accepted answer
  1. Rich Matheisen 45,671 Reputation points

    This should work:

    $desiredmodels = "HP Color LaserJet 2605","HP LaserJet 3050 AIO","SL-K4350LX"
    $OutputDirectory = "c:\junk\"
    [array]$Downloads = @()
    $inaprinter = $false
    $info= @{}
    ForEach ($l in ($x.content -split ("`r`n"))) {
            if ($l.Trim().Length -lt 1){
                Continue                    # skip empty lines
            if ($l.substring(0,2) -eq ";;"){
                # do nothing, it's just a comment
            if ($l.substring(0,1) -eq "["){ # the start of a new printer data set
                if ($inaprinter -and $info['download'] -eq $true){  # if there's a completed record, save it
                    $Downloads += [PSCustomObject]$info
                $inaprinter = $true
                $info['download'] = $false
                Continue                        # not interested in the name, just the fact that it's the beginning
            $l = $l -replace " \t+="," ="            # some data sets place tabs immediately before the '='! Remove them.
            [array]$p = $l -split " = "
            if ($p.count -ne 2){        # only interested in lines like X = Y
            switch ($p[0]) {
                "SupportedModels" {
                    [array]$models = $p[1].split(";",[System.StringSplitOptions]::RemoveEmptyEntries)
                    if ($models.count -gt 0){
                        ForEach ($model in $models){
                            if ($desiredmodels -contains $model){
                                $info['download'] = $true
                "Path" {$info[$p[0]] = $p[1]; break}
                "Name" {$info[$p[0]] = $p[1]; break}
    if ($inaprinter -and $info['download'] -eq $true){  # in case there's pending record
        $Downloads += [PSCustomObject]$info
    $Downloads |
            Invoke-WebRequest -Uri $_.Path -OutFile "$OutputDirectory$($_.Name)"

0 additional answers

Sort by: Most helpful