Create HP BIOS Repository using PowerShell

First off, I love SCConfigMgr Driver / BIOS download tool, super powerful and fully featured.

Sometimes you just want a lightweight script to run that will do a specific task over and over.

Using the HP Client Management Script Library, Documentation HERE, I’ve created a simple Script that will go through a list of models that I’ve created, and download the BIOS Files, then extract the bin file to a separate directory. (I delete all of the extra support EXE files, as I’d only want one set in my entire package, not one for each model)  After this, I can then create a package around it, and deploy.  I’m not including that process here today, just the download.  I’ll probably blog more on this topic in the future, along with a script that runs locally on the machine that requires the update, which will download the update right from HP, then install it… but not today... UPDATE.. YES TODAY! Check it out HERE

Today, simple script to download BIOS file right from HP.

  1. Downloads BIOS for specified Models in Script into Download Source Folder Structure
  2. Extracts BIOS & Updater into "Package" Folder Structure
  3. If you re-run
    1. Skips current BIOS downloads by comparing Download Structure to what is available from HP
    2. if it finds updated BIOS available
      1. Downloads Updated BIOS into New Folder (Download Structure)
      2. Deletes old Package Contents and Updates it with the new BIOS (Package Structure)
<#  Creator @gwblok - GARYTOWN.COM
    Used to download BIOS Updates from HP, then Extract the bin file.
    This Script was created to build a BIOS Update Package. 
    Future Scripts based on this will be one that gets the Model / Product info from the machine it's running on and pull down the correct BIOS and run the Updater

    REQUIREMENTS:  HP Client Management Script Library
    Download / Installer: https://ftp.hp.com/pub/caps-softpaq/cmit/hp-cmsl.html  
    Docs: https://developers.hp.com/hp-client-management/doc/client-management-script-library-0
    This Script was created using version 1.1.1
#>

#Reset Vars
$BIOS = ""
$Model = ""
$HPModelsTable = ""
$HPModelName = ""
$CurrentDownloadedVersion = ""

$OS = "Win10"
$Category = "bios"
#$HPModels = @("80FC", "82CA")
$DownloadDir = "C:\HPContent\Downloads"
$ExtractedDir = "C:\HPContent\Packages\HP"
    
        $HPModelsTable= @(
        @{ ProdCode = '80FC'; Model = "Elite x2 1012 G1"}
        @{ ProdCode = '82CA'; Model = "Elite x2 1012 G2" }
        @{ ProdCode = '80FB'; Model = "EliteBook 1030 G1" }
        @{ ProdCode = '80FA'; Model = "EliteBook 1040 G3"  }
        @{ ProdCode = '225A'; Model = "EliteBook 820 G2"  }
        @{ ProdCode = '807C'; Model = "EliteBook 820 G3"  }
        @{ ProdCode = '2216'; Model = "EliteBook 840 G2"  }
        @{ ProdCode = '8079'; Model = "EliteBook 840 G3"  }
        )
        $HPModelName = $HPModelsTable | ? ProdCode -eq $Model | % Model


foreach ($Model in $HPModelsTable)
    {
    Write-Output "Checking Product Code $($Model.ProdCode) for BIOS Updates"
    $BIOS = Get-SoftpaqList -platform $Model.ProdCode -os $OS -category $Category
    if (Test-Path "$($DownloadDir)\$($Model.Model)"){$CurrentDownloadedVersion = (Get-childitem -Path "$($DownloadDir)\$($Model.Model)").Name}
    $MostRecent = ($Bios | Measure-Object -Property "ReleaseDate" -Maximum).Maximum
    $BIOS = $BIOS | WHERE "ReleaseDate" -eq "$MostRecent"
    $DownloadPath = "$($DownloadDir)\$($Model.Model)\$($BIOS.Version)"
    $ExtractedPath = "$($ExtractedDir)\$($Model.Model)"
    
    if (-not (Test-Path "$($DownloadPath)"))
        {
        if ($CurrentDownloadedVersion) {Write-Output "Update Found, Replacing $([decimal]$CurrentDownloadedVersion) with $([decimal]$BIOS.Version)"}
        Else {Write-Output "Update Found, Downloading: $([decimal]$BIOS.Version)"}
        Write-Output "Downloading BIOS Update for: $($Model.Model) aka $($Model.ProdCode)"
        Get-Softpaq -number $BIOS.ID -saveAs "$($DownloadPath)\$($BIOS.id).exe" -Verbose
        Write-Output "Creating Readme file with BIOS Info HERE: $($DownloadPath)\$($Bios.ReleaseDate).txt"
        $BIOS | Out-File -FilePath "$($DownloadPath)\$($Bios.ReleaseDate).txt"
        $BiosFileName = Get-ChildItem -Path "$($DownloadPath)\*.exe" | select -ExpandProperty "Name"
        
        if (Test-path $ExtractedPath) 
            {
            Write-Output "Deleting $($ExtractedPath) Contents before extracting new contents"
            remove-item -Path $ExtractedPath -Recurse -Force
            }
        Write-Output "Extracting Downloaded BIOS File to: $($ExtractedPath)"
        Start-Process "$($DownloadPath)\$($BiosFileName)" -ArgumentList "-pdf -e -s -f$($ExtractedPath)" -wait
        #Start-Sleep -Seconds 2
        $BIOS | Out-File -FilePath "$($ExtractedPath)\$([decimal]$Bios.Version).txt"
        #Start-Sleep -Seconds 2
        #Write-Output "Deleting support files, leaving only the BIOS.bin file & 64Bit Updater"
        Remove-Item -Path "$($ExtractedPath)\*.rtf" -Verbose
        Remove-Item -Path "$($ExtractedPath)\*.log" -Verbose
        Remove-Item -Path "$($ExtractedPath)\Hpq*.exe" -Verbose
        Remove-Item -Path "$($ExtractedPath)\HPBIOSUPDREC.exe" -Verbose
        
        Start-Sleep -Seconds 3
        }
    Else
        {Write-Output "No New BIOS Available"}
    }

 

Running Script:
image

File Output – Downloads Folder:
image

Extracted Folder:

image

Posted at GARYTOWN.COM

4 thoughts on “Create HP BIOS Repository using PowerShell”

  1. There are a lot of commands here I don't understand where they are coming from. Such as "Get-SoftpaqList" how do I get these commands to run? What am I missing?

    Reply

Leave a Comment

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