Automating HP SoftPaq Repository Updates Using PowerShell

A couple of years ago, I moved away from importing drivers into ConfigMgr for our HP laptop and desktop computers. This was accomplished by creating SoftPaq repositories, and applying them during OSD/IPU task sequences using HP System Software Manager. This approach makes for easy replacement of older drivers as there is no importing involved. A future blog post will show that setup.

I previously used HP SoftPaq Download Manager to download SoftPaqs and their corresponding CVA files, of which both are needed to silently install using SSM. Due to a great lifecycle strategy, our environment consists of 7 total unique computer models (4 laptop, 3 desktop). Even with so few models, it was still tedious to maintain the SoftPaq repositories manually. I would need to check if new versions were available, remove old versions, update the SSM database, and update distribution points. Automating that process is much more appealing.

Enter HP Client Management Script Library! In July of 2018, HP introduced a library of PowerShell scripts that can be used to automate this entire process. I am a bit new to PowerShell scripting, but have taken inspiration from others to share my solution. Please share feedback in the comments, as I am sure there are improvements that could be made to my solution below. A couple bloggers that I ‘borrowed’ code from for are Gary Blok (@gwblok) and Ryan Ephgrave (@ephingposh). I also receive excellent help from Nathan Kofahl (@nkofahl) who is with HP. Thanks to you all for your work!

The following script will loop through the models table and do the following:

1. Update an existing repository or create a new repository if one doesn’t exist
2. Setup email alerts to notify of sync failures
3. Invoke a repository sync for bios and driver categories
4. Invoke a repository cleanup to remove old versions
5. Ensure the needed SSM files are up to date
6. Rebuild the SSM database

NOTES:
Running the Script: The script can be run on demand or as a scheduled task. Unless you include the -quiet switch on the Invoke-RepositorySync command, you should see something similar to the following when running the script.

Script running, currently in the Invoke-RepositorySync step for an HP EliteDesk 800 G3 DM 35W

Logging: The logging feature was created by @EphingPosh and is posted at https://www.ephingadmin.com/powershell-cmtrace-log-function/. In my environment, I added this as a separate module, but it could be added to the top of the script as well. This logging is done in CMTrace format for easy readability.

CMTrace formatted script log

Repository Logging: In addition to the script log, HP has a useful repository log called activity.log located in the \.repository subfolder. This shows information about all repository activity (total number of SoftPaqs to be downloaded, what file is currently being downloaded to the repository, etc).

CVA Files: The CVA files that accompany each SoftPaq include the details about what models the SoftPaq is applicable, among other info. These files are frequently updated, so the Invoke-RepositorySync downloads and overwrites these files at every sync. They are very small text files, so this step does not usually increase the script runtime significantly.

SSM Configuration: SSM is a versatile utility. I initially used it as a standalone solution, implemented by a startup script. Configuration of what is needed for both solutions is documented in my Configuring HP SSM blog post. Follow that post, and copy the resulting files for the task sequence section into your ‘SSM Base’ folder, which is located at the root of the repository path.

24 thoughts on “Automating HP SoftPaq Repository Updates Using PowerShell

  1. Nice guide! Thanks 🙂 We use SSM also in our sequence but only for bios updates. The repo you’re making is that on 1 server because we have several remote DP servers so if files must go over WAN that’s tricky.

    Like

    1. The full repository is on one server. Each individual model repository is the data source path for a package in ConfigMgr. That package gets content distributed to DPs, and ConfigMgr distributes updated content as the repositories change.

      Like

  2. Hello! I know this is kinda off topic but I was wondering which blog platform are you using for this website? I’m getting sick and tired of WordPress because I’ve had problems with hackers and I’m looking at alternatives for another platform. I would be great if you could point me in the direction of a good platform.

    Like

  3. Hi! Great post! I wrote a similar script to sync our driver packages. One thing I did a little bit different and would like to tell you if I may. The hash table is a nice idea but if you get new devices you have to change the script directly. Or you set up your idea for a different customer with other models. I use a very simple xml file with exactly the same information. This is IMHO much easier to maintain using Excel or so. Do you know what I mean? If you are interested I can share my script with you.

    Like

    1. I believe the cab file that the platform/osver references has the info for the models that have multiple video cards. Both softpaqs get downloaded. I have one such model in my environment if I remember correctly. I can check out which video softpaqs the script downloaded when I get back to a computer.

      Like

  4. Im getting the following error when running the script:

    “Log : The term ‘Log’ is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.”

    Like

  5. Awesome. But I don’t understand why you would want the script to rebuild the ssm database after every new download? Why not download, clean and then rebuild the database?

    Like

  6. Hi Ryan,

    This looks great. One question, where can I find your “Configuring HP SSM” blog post?
    I’ve installed and run SSM but I can’t find the SSM.exe file.

    Thanks,
    Phil.

    Like

  7. Great tool! Question. Is there a way to limit what drivers get downloaded/synced? Let’s just assume I only need BIOS, ME and Graphics

    Like

  8. Great works, I just implement and it works very well.
    I do have some problem, with some clients that three versions of Intel graphic driver and when I run the update script they installs again.
    The machine already have those drivers installed, so it should just go on without installing them. Strange..
    I have trouble to find a good forum for HP SSM.. anyone know some good resources for that?

    Like

  9. Hi Ryan,

    Thanks for the awesome script. Is it possible to only just download the drivers and bios without having the SSM installed?

    Thanks,
    Steve

    Like

    1. Hi Steve. The script loops through the model table and downloads/updates a repository for each model. At the very end of the loop, the script uses robocopy to confirm the SSM files are up to date in each repository. You can simply comment out/remove the lines for the robocopy section of the script and it will skip.

      Like

  10. Scripting newb here looking for some assistance. When I run the scripts in PS, I am getting this:
    Log : The term ‘Log’ is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a
    path was included, verify that the path is correct and try again.
    At D:\SSM_SDM\UpdateRepos.ps1:34 char:5
    + Log -Message “————————————————— …
    + ~~~
    + CategoryInfo : ObjectNotFound: (Log:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

    Log : The term ‘Log’ is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a
    path was included, verify that the path is correct and try again.
    At D:\SSM_SDM\UpdateRepos.ps1:35 char:5
    + Log -Message “Checking if repository for model $($Model.Model) ak …
    + ~~~
    + CategoryInfo : ObjectNotFound: (Log:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

    Log : The term ‘Log’ is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a
    path was included, verify that the path is correct and try again.
    At D:\SSM_SDM\UpdateRepos.ps1:36 char:59
    + if (Test-Path “$($RepositoryPath)\$($Model.Model)”) { Log -Messag …
    + ~~~
    + CategoryInfo : ObjectNotFound: (Log:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

    Log : The term ‘Log’ is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a
    path was included, verify that the path is correct and try again.
    At D:\SSM_SDM\UpdateRepos.ps1:60 char:9
    + Log -Message “Repository not initialized, initializing now” – …
    + ~~~
    + CategoryInfo : ObjectNotFound: (Log:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

    Initialize-Repository : The term ‘Initialize-Repository’ is not recognized as the name of a cmdlet, function, script file, or operable program. Check
    the spelling of the name, or if a path was included, verify that the path is correct and try again.
    At D:\SSM_SDM\UpdateRepos.ps1:62 char:9
    + Initialize-Repository
    + ~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : ObjectNotFound: (Initialize-Repository:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

    Log : The term ‘Log’ is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a
    path was included, verify that the path is correct and try again.
    At D:\SSM_SDM\UpdateRepos.ps1:67 char:13
    + Log -Message “Failed to initialize repository for $($Mode …
    + ~~~
    + CategoryInfo : ObjectNotFound: (Log:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

    Like

Leave a comment