Automating Maintenance of HP Image Assistant Repositories (Upd 8/10/2021)

HP Image Assistant can install/update drivers and other components from an offline repository that has been populated with Softpaqs for HP supported business systems. A Repository folder, if to be used by HPIA, requires to be configured correctly. Configuring can be done with HP's Client Management Software Library. This blog highlights a Powershell script that helps automate the creation and maintenance of such repositories

In previous blogs, we reviewed methods to inject drivers with HP Image Assistant into Microsoft Endpoint Configuration manager. The methods described in the blog used file repositories managed by the HP’s Client Management Script Library. HP Image Assistant (HPIA), while running on a client PC during imaging steps can draw the latest drivers from the managed repository and inject them facilitating the process of imaging new PCs. On a different blog, we discussed how to update drivers with HPIA to help enterprises keep deployed systems up to date. Here we packaged HPIA as an application that with a runstring option connected to a server-hosted file repository, where it pulled newer Softpaqs for the client it is running on.

The script described here, and hosted on Github, is designed to create file repositories as required from each model selected in the GUI, configure them for HPIA and when clicking on Sync, download all available Softpaqs (latest only) for the selected categories.

As with previous blogs, the script requires that the HP CMSL module be loaded on the system (PC or server) it runs on. Otherwise, PowerShell will complain on the use of repository cmdlets within the script. The module can be loaded from the PS Gallery - as Administrator: 

Import-Module -name 'HPCMSL' -SkipPublisherCheck -AcceptLicense -Force

Note that for some systems, the PowerShellProvider NuGet and module PowerShellGet may need to be updated to add the HPCMSL module from the Gallery.

Install-PackageProvider -name NuGet -Force
Install-Module PowerShellGet -SkipPublisherCheck -Force
Update-Module -Name PowerShellGet

 

Also, note that PoweShell scripts have to be allowed to execute. If needed, scripts can be enabled with a command such as

Set-executionpolicy -ExecutionPolicy RemoteSigned -Scope LocalMachine

The script interface will keep track of what is selected, and repopulate the settings on restart.

The script will

  • Check for the presence of the HP CMSL module - TBD with feature update
  • Will read the contents of the INI file to retrieve local, specific, information, including
    • OS Version selected
    • Categories of Softpaqs to be used as filters (each in its own column)
    • Models list
    • Path to host repositories, with each model having its own folder repository
    • Path to log file
    • Setting to enable access to the local MECM environment to create/update repository packages. If disabled, the script will ONLY populate repositories. The setting is shown on the user interface, where it can also be modified
  • Will check for the main repository folder, and create it if not already created
  • If any models are already selected (from a previous run), it will check for repository filters and populate the GUI accordingly.
  • For each model selected. The appropriate path is shown in the last column
  • Provides a Sync button to sync and clean up each repository the user selects for update

NOTE: selecting a different OS Version in the GUI will make that version default to all systems. Pressing Sync will then have the HP CMSL repository commands search for Softpaqs matching each category and OS version to update the model’s repository.

The first column of checkmarks indicate if ANY model has some selected categories to sync. Putting a checkmark on this column will also select the ‘Driver’ category. The reason is simply that in most cases, HPIA is used to update hardware-enabling drivers so we chose to set it automatically. On the same row, selecting from the ‘All’ column will select/enable all categories for that model.

The local configration options are kept in an ini file, HPIARepo_ini.ps1

<#
    File: HPIARepo_ini.ps1
    Dan Felman/HP Inc
    7/23/2020
    modify variables as need for use by the Downloader script
#>
$OS = "Win10"
$OSVER = "1909"                                # entry can be midified in the GUI
$OSVALID = @("1809", "1903", "1909", "2004")   # add/remove as needed
$FilterCategories = @('Driver','BIOS', 'Firmware', 'Software')
#-------------------------------------------------------------------
# Example systems to manage
#
$HPModelsTable = @(
    @{ ProdCode = '8438'; Model = "HP EliteBook x360 1030 G3" }
    @{ ProdCode = '83B3'; Model = "HP ELITEBOOK 830 G5" }
    @{ ProdCode = '83B2'; Model = "HP ELITEBOOK 840 G5" }
    @{ ProdCode = '8549'; Model = "HP ELITEBOOK 840 G6" }@{ ProdCode = '8470'; Model = "HP ELITEBOOK X360 1040 G5" }
    @{ ProdCode = '844F'; Model = "HP ZBook Studio x360 G5" }
    @{ ProdCode = '8593'; Model = "HP EliteDesk 800 G5 Desktop Mini PC" }
    @{ ProdCode = '8549'; Model = "HP EliteBook 840 G6 Healthcare Edition" }
    @{ ProdCode = '859F'; Model = "HP EliteOne 800 G5 All-in-One" }
    )
$FileServerName = $Env:COMPUTERNAME 

# choose/edit a path from next 2 lines for the location of the main repository folder
# next for use in multiple repositories/one per model
$RepoShareMain = "\\$($FileServerName)\share\softpaqs\HPIARepo"
#$RepoShareMain = "C:\share\softpaqs\HPIARepo"

# 7/23 NEW: and this for use when selecting a single repository (use with Script version >= 1.15
$RepoShareSingle = "\\$($FileServerName)\share\softpaqs\HPIACommonRepository"
#$RepoShareSingle = "C:\share\softpaqs\HPIACommonRepository"

$LogFile = "$PSScriptRoot\HPDriverPackDownload.log"               # Default to location where script runs from

# next setting makes the script work with Microsoft SCCM/MECM, if set to $true
# it can be modified in the main script, as needed
$UpdateCMPackages = $False

# 7/21 NEW: manage single repository folder, instead of individual per model
$SingleRepo = $False

# if there are errors during startup, set this to $true, for additional startup info
$DebugMode = $false

Selecting 'Debug Mode' allows the script to output additional steps it is doing

If a row/Model is deselected, the script will NOT attempt to remove the contents of the repository if one existed. It will remain in place. The contents of the repository can be cleaned up by removing the folder, that includes all softpaqs, the .Reporitory folder, etc.

Update 1.10

This update of the Repository downloader script adds the ability to select a single repository for all models. The checkmark, when selected, will be maintained in the INI file

Version 1.15

This version adds a separate variable for a common/master repository instead of using the main repo used as the head of individual repositories. To set it up, modify the Main share variable (as either a \\ share, or a driver letter C:\... pick one line in the INI file to suite your environment - change as appropriate

$RepoShareMain = "\\$($FileServerName)\share\softpaqs\HPIARepo"
#$RepoShareMain = "C:\share\softpaqs\HPIARepo"

and do the same for using a common/single master repository for all systems

$RepoShareSingle = "\\$($FileServerName)\share\softpaqs\HPIACommonRepository"
#$RepoShareSingle = "C:\share\softpaqs\HPIACommonRepository"

To clean up repositories:

If single repository, all filters are removed during a Sync and the following cleanup will remove any softpaqs not part of the selected models and categories in the GUI.

For individual repositories, there is a general clean up any time a category changes. To remove a model, just delete the repository folder.

Update 1.30

In order to provide the ability to select specific Softpaqs to download and maintain for HPIA's use, the script was modified to allow a select 'named' set of softpaqs be downloaded on a per model basis. The updated INI file extends the $HPModelsTable to include a list of Softpaqs to keep track of. The Main script then downloads each in its own repository subfolder (so that CMSL's Invoke-RepositorySync/Cleanup will not delete them) and copies those files to the repository as appropriate.

The INI file is then modified, for example...

<#
    File: HPIARepo_ini.ps1

    Dan Felman/HP Inc
    7/27/2020

    modify variables as need for use by the Downloader script
#>
$OS = "Win10"
$OSVER = "2004"
$OSVALID = @("1809", "1903", "1909", "2004")

$FilterCategories = @('Driver','BIOS', 'Firmware', 'Software')

#-------------------------------------------------------------------
# Example systems to manage
#
# NEW 1.30 - added list of individual softpaq names to host in repository
$NBSet1 = 'HP Collaboration Keyboard Software' , 'HP Hotkey Support' , 'System Default Settings for Windows 10' , 'HP Notifications'
$NBSet2 = 'HP Hotkey Support' , 'System Default Settings for Windows 10' , 'HP Notifications'
$DTSet1 = 'HP Notifications'

$HPModelsTable = @(
	@{ ProdCode = '8598'; Model = "HP ProDesk 600 G5 DM";                   SqName = $DTSet1  }
	@{ ProdCode = '8438'; Model = "HP EliteBook x360 1030 G3";              SqName = $NBSet1  }
	@{ ProdCode = '83B3'; Model = "HP ELITEBOOK 830 G5";                    SqName = $NBSet1  }
	@{ ProdCode = '83B2'; Model = "HP ELITEBOOK 840 G5";                    SqName = $NBSet1  }
	@{ ProdCode = '8549'; Model = "HP ELITEBOOK 840 G6";                    SqName = $NBSet2  }
	@{ ProdCode = '8470'; Model = "HP ELITEBOOK X360 1040 G5";              SqName = $NBSet1  }
	@{ ProdCode = '844F'; Model = "HP ZBook Studio x360 G5";                SqName = $NBSet1  }
	@{ ProdCode = '8593'; Model = "HP EliteDesk 800 G5 Desktop Mini PC";    SqName = $DTSet1  }
        @{ ProdCode = '8549'; Model = "HP EliteBook 840 G6 Healthcare Edition"; SqName = $DTSet1  }
        @{ ProdCode = '859F'; Model = "HP EliteOne 800 G5 All-in-One";          SqName = $DTSet1  }
    )

$FileServerName = $Env:COMPUTERNAME 

#-------------------------------------------------------------------
# choose/edit a path from next 2 lines for the location of the main repository folder

# next for use in multiple repositories/one per model
$RepoShareMain = "\\$($FileServerName)\share\softpaqs\HPIARepo"
#$RepoShareMain = "C:\share\softpaqs\HPIARepo"

# 7/23 NEW: and this for use when selecting a single repository (use with Script version >= 1.15
$RepoShareCommon = "\\$($FileServerName)\share\softpaqs\HPIACommonRepository"
#$RepoShareCommon = "C:\share\softpaqs\HPIACommonRepository"

#-------------------------------------------------------------------
$LogFile = "$PSScriptRoot\HPDriverPackDownload.log"               # Default to location where script runs from

#-------------------------------------------------------------------
# next setting makes the script work with Microsoft SCCM/MECM, if set to $true
# it can be modified in the main script, as needed
$UpdateCMPackages = $False
$DistributeCMPackages = $False

#-------------------------------------------------------------------
# 7/21 NEW: manage single repository folder, instead of individual per model
$CommonRepo = $False

# if there errors during startup, set this to $true, for additional info
$DebugMode = $false

There is also a general cleanup of the messages displayed with more of them only available when either the '[ ] Debug mode' checkbox is set or the variable in the INI file is set to $True (for additional startup debug messages that would not be seen if problems arise before the UI is created)

Version 1.25 and newer also include a new' [ ] Distribute Packages' checkmark to allow the creation/update of SCCM packages to not automatically update distribution points, unless desires

The 'Clear TexBox' button clears out the message box, and the new 'Refresh Grid Filters' button will refresh the list from information on the File Repositories.

NOTE: named Softpaqs are downloaded to a .ADDSOFTWARE subfolder. If this folder is removed, it will be recreated on next Sync. Also, there is no Softpaq maintenance done, so if a newer version for a particular Softpaq is downloaded, the previous version is not deleted, but it can be removed manually if the space is needed.

Version 1.32

This version adds the ability to create an HPIA package in SCCM, and update it should the program upgrade to a new version. Pressing on [Update HPIA] button checks to make sure SCCM is available on the system the script runs and then either creates a package pointing the source to the HPIA folder, or updates the package with the folder listed in the INI (and shown in the UI).

The message textbox will also show sync information from the last invoke-reporitorysync command, which is also posted to the script's log file.

version 1.40

This version adds several enhancements. First, the size of the dialog has increased to allow for better use of display. A new checkbox allows the user to maintain existing filters (say, for an older OS version while adding filters for a new OS). The checkbox is just below the Sync button. Then, there is the ability to list all existing filters for each system. Finally, we added buttons to increase (and decrease) the text box up to 4 sizes for better legibility

version 1.45

In order to help diagnose HP Script Library sync issues, code was added to attempt to obtain the remote connection's IP address. If obtained, the remote and local (public) IP addresses are displayed in the UI as well as logged in the script's log file. The connection information is tied to the function and CMSL cmdlet for help in troubleshooting steps

In addition, the log file name is now also shown in the UI (retrieved from the INI.ps1 file

version 1.50

        Added protection against Platform/OS Version not supported
        Added ability to start a New log file w/checkmark in IU - log saved to log.bak0,log.bak1, etc.

version 1.51

Removed All column (was selecting all categories with single click
Added 'INI S/W' column to allow/disallow download of software listed in INI.ps1 file
Fixed UI issues when clicking/selecting or deselecting categories and Model row checkboxes

version 1.62 (9/16/2020)

Versions newer then 1.60 add runtime options. The script will now be able to be scripted and executed as a Windows scheduled job

When running the script with runtime options, it assumes repositories have been created and available. If the -Products runtime option is added, only the list of product IDs will be sync'd and nothing else will be touched. If -Products is not added, then the list of systems will be obtained from the INI.ps1 file, again it will assume that the script was run in UI mode first and repositores for those systems are alreay created  with the appropriate filters

Option -help will show options and terminate

Option -Sync will execute the script with or without additional options

The following options are available:

-help|-h
-inifile <path to ini.ps1 file>                   # Defaults to ".\HPIARepo_ini.ps1"... can also be 1st arg in command line
-RepoStyle <Individual | Common>      # Defaults to setting in ".\HPIARepo_ini.ps1"
-Products @()                                       # List of Produc ID's... default is to use existing repositories
-ListFilters                                             # Switch: to show what filters exist in each reporitory
-noIniSw                                                # Switch: to disable use of alternate named Softpaqs by name in INI file
-showActivityLog                                   # Switch: enable output of additional activity from HPIA log file
-new Log                                               # Switch: back up existing log file and start new script log
-Sync                                                    # Switch: command to sync and maintain repositories
 

A sample job scheduling script is available on Github, and shown next

<#
    reposcriptTest.ps1

    Developed by:
        Dan Felman
        HP Inc Technical Consultant
        9/15/2020

    This is a sample script to show how to schedule the HPIARepo_Downloader script v1.62 and later with runtime options

    'HPIARepo_Downloader' runtime options:

    -IniFile <filepath.ini> -ListFilters -RepoStyle <common|individual> -Sync -NoIniSw -ShowActivityLog -Products <>80D4,8549,8470> -newLog 

        -IniFile   defaults to '.\HPIARepo_ini.ps1'
        -RepoStyle defaults from $CommonRepo variable in IniFile
        -Products  defaults to $HPModels list in IniFile. 
            In either case, corresponding repositories must exist, or product is bypassed

    NOTE: modify location for local environment
          modify options as needed
#>

# this is the PS script block that gets scheduled... modify as needed

$HPIABlock = { 
    & Set-Location 'C:\Users\Administrator.VIAMONSTRA\Documents\Manageability_demo_files\Scripts\WiP'
    & .\HPIARepo_Downloader_1.62.ps1 -ListFilters -RepoStyle individual -ShowActivityLog -Sync -NoIniSw -Products 80D4,8549,8470 -newLog 
}

# let's schedule the Downloader as a Windows Task job
# if job (by name) already exists, just report it, otherwise, schedule it

#--------------------------------------------------------------------------------------

$scheduleTime = '16:56'                           # NOTE: Modify when to schedule job                      

$doJob = $true                                    # default is to schedule the job
$ScheduledJobs = Get-ScheduledJob                 # obtain existing scheduled jobs
$TriggerName = 'HPIATrigger'                      # name of the job... Modify if needed

# find out if the Trigger is already in use

if ( $ScheduledJobs -ne $null ) {
    foreach ( $currJob in $ScheduledJobs ) {
        if ( $currJob.Name -match $TriggerName ) {
            $doJob = $false
            write-host "Trigger found (shown next). Can't schedule another Job with same Trigger name. To remove type: 'Unregister-ScheduledJob -id $($currJob.id)'"
            Get-ScheduledJob -Name $TriggerName
        } # if ( $currJob.Name -match 'HPIATrigger' )
    } # foreach ( $currJob in $jobs ) 
}

# If Trigger not yet scheduled, let's do it now
# but make sure we have admin rights first

if ( $doJob ) {
    $adminRights = ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")
    If( $adminRights ) {
        'Scheduling job. User is a member of local administrators'
        ## NOTE some Options: 
        ##    -Once <-At "1/20/2012 3:00 AM">
        ##    -Weekly -DaysOfWeek <DayOfWeeklist[]> <-At "3:00 AM">
        ##    -Daily <-At "1/20/2012 3:00 AM">
        ##    -AtLogon
        ##    -AtStartup
        ## ( https://docs.microsoft.com/en-us/powershell/module/psscheduledjob/new-jobtrigger?view=powershell-5.1 )
        $trigger = New-JobTrigger -Once -At $scheduleTime          
        Register-ScheduledJob -Name $TriggerName -Trigger $trigger -ScriptBlock $HPIABlock
    } Else {
        'Can not schedule job. User is not a member of local administrators'
    } # else If( $adminRights )
}

#--------------------------------------------------------------------------------------
# Powershell scheduling job commands
#--------------------------------------------------------------------------------------

# Get-ScheduledJob
# Get-ScheduledJob -Name HPIATrigger
# Unregister-ScheduledJob -Name HPIATrigger

# Remove-JobTrigger -Name HPIATrigger

version 1.65

Adds Browse button for sourcing updated HP Image Assistant folder... requires finding HPImageAssistant.exe

Adds support for managing Softpaqs by SP name in INI file

version 1.66

Adds dialog during Sync to remove (or not) not selected filters and softpaqs from repository that were selected previously --- this is a way to remove Softpaqs from models no longer needed

version 1.70

Adds a checkbox in the GUI to enable the CMSL Sync command to continue should it encounter a File NOT Found error (404). The default is set to True in HPIARepo_ini.ps1

version 1.75

Adds the ability to import an existing HPIA repository and update the INI file accordingly

Adds OS selected version support check for plarforms 'checked' in the grid - in advisory mode

version 1.80 - July/2021

Restructured GUI based on feedback to make it easier to follow steps and use case

Added Browse buttons for both Individual and shared/Common repositories to allow existing repositories to be used with the tool, right from the GUI. The new, browsed, repositories can be set as the new default in the INI.ps1 file or not, based on needs. If not set as default, next time the script is run it will show what was set as default again

The revamped User Interface now looks like this:

As can be seen, the Sync button was moved, and is now shown after the Models List grid, and renamed 'Sync Repository'.

A new 'Get Models from INI' button retrieves and displays the list of models from the INI.ps1 file. Useful when using different repositories, or creating a new one with 'Browse' and want to then sync with the listed models in the INI file

When using 'Browse' to select an existing repository, the tool will now ask if the content (models) in the repository should be made the new default list in the INI file. If so, the next time the script is run, it will start with the new list and pointing to the acquired repository

The AddOns column indicate that a number of Softpaqs should be maintained by the script, outside of the default categories, like Drivers and BIOS. The list of Softpaqs needs to be (manually) maintained in the INI file, and there is an example showing how to add the list for each platform. The script can maintain Software Softpaqs like HP Hotkeys, HP Notifications, etc.

When the INI.ps1 file model entry contains the AddOns tag with its list, like this:

@{ ProdCode = '842A'; Model = 'HP ZBook 15 G5 Mobile Workstation' ; AddOns = 'Hotkeys', 'Notifications', 'Default Settings' } 

and the AddOns cell for a platform is checked for, the Downloader script will download the latest version of each Softpaq named in the 'AddOns' list to a separate .\ADDSOFTWARE repository folder and make it available to HPIA after every Sync and Cleanup (done when clicking on the 'Sync Repository' button). That would allow HPIA, when connecting to the repsitory, to include category Software in the runstring and install ONLY those Softpaqs listed in the INI.ps1 file

Note that the script will match Softpaqs' by name to whatever it is shown on the list. If more than one Softpaq matches a listed name, all the Softpaqs matching the named string would be downloaded and maintained. Also, resetting (unchecking) the AddOns cell just removes the flag in the .ADDSOFTWARE folder but does NOT remove any of the downloaded Softpaqs

The MEM CM/SCCM connection bar area and setting properties for HPIA and packages was moved below the 'Sync Repository' button and highlighted to show it is a separate function from the main Softpaq downloader function

Due to the enhancements in the script, please download and use both the new version of the main script file AND the INI.ps1 file from GitHub

version 1.85 - August/2021

Added ability to start from scratch with an empty list of models and a new repository folder

A new 'Add Model' button allows the user to find and add a supported HP system to the grid, which is then used to create and maintain the respository (or individual respositories). The AddOns entry for each model can then be added to the INI file list and selecting the AddOns checkmark for the model will allow the script to set up the extra flag required to source additional software Softpaqs

in addition, a User Guide for the tool is now available, also in the GitHub repository

Author : dan.felman

HPIA downloader PS script

The top part to add the module is not correct this worked for me . Install-Module -Name HPCMSL -SkipPublisherCheck -AcceptLicense -Force

it has been kind of hard to figure out the proper requirements for having all things needed to support importing the CMSL module... 1) after updating powershellget module, the program and PS need to exit and restart (i am adding this to code as we speak)... 2) try removing the -AcceptLicense option from the runstring

You should not normally need the -SkipPublisherCheck. However I believe the signing certificate CN has changed between 1.4 and 1.5, which will cause a warning, since PS will see a different certificate for 1.5.

How do I handle this: PS C:\WINDOWS\system32> Get-HPDeviceDetails -platform '8079' SystemID Name DriverPackSupport -------- ---- ----------------- 8079 HP EliteBook 840 G3 Notebook PC True 8079 HP EliteBook 848 G3 Notebook PC True 8079 HP EliteBook 850 G3 Notebook PC True 8079 HP ZBook 15u G3 Mobile Workstation True They are the same product code but different names. We have the top three in this list. Do I put in 3 entries or just 1?

very good question. because the repositories, when using individual folders are based on system names, you would have to include each model in the list. However, an option could be that you use a single model, say the HP EliteBook 840 G3 and then point your HPIA run to that repository for each model - and remember that since the CMSL repository commands sync the repository for the product code (in this case 8079), it would support all 3 versions of the G3 laptops. This would prevent triplicating the repositories, one per model on the other hand, if you setup a shared/common repository for all models, then you can have all models listed in the HPModels list and once the filters are applied in the UI, the Sync and Cleanup commands would make sure no duplicate Softpaqs are maintained. BTW, i have developed a new version (to post soon) that includes runtime options, which would allow the Downloader script to be scheduled to run on a regular basis. Hopefully, it will be useful to some users

Hi Dan I am trying to integrate HPIA into Task Sequence, and we have offline shares setup, and I use your version 1.7 offline downloader. My question is: there are some variations when I do HPIA in Task Sequence and download HPIA off HP website and run it against my device. For example: HP EliteBook 830 G6, there are 2 drivers that are different between online and offline. 830 G6 Online HPIA: Out of date drivers: sp110459 (Intel® Management Engine Interface) and sp111901 (Intel ® UHD Graphics 620) Task Sequence (HPIA): sp107489 (Intel® Management Engine Interface) and 105485 (Intel ® UHD Graphics 620) So my question is: Drivers I download for offline, does the cabinet file govern what drivers get downloaded for each device? Am I meant to get some different when I run HPIA offline or online? Thanks Michael

@michaelhung - As far as HPIA is concerned, it will not matter if it runs against an offline repository, or directly from hp. HPIA does its magic based on the reference file associated with the device and OS version it is running on. The latest 'updated' reference file is always first posted at hp, and when you run a CMSL sync on your offline repository the version now available is downloaded for the products/OS version (e.g. 'filters') in the repository, so that if you do a sync and cleanup prior to running HPIA in offline mode, the reference files used to compare would be the same as the one on hp.com. If you find that HPIA still shows needs to update a driver after it run once, i suggest you work with your HP Technical Consultant to escalate the issue. It is possible that a driver Softpaq or associated CVA may need to be updated or fixed. Or perhaps HPIA needs some corrections

Hi Dan, i know this is not quite a repository question, but my question is around: is it possible to control how HPIA installs different drivers/firmware? e.g. i want wifi to be done last that kinda thing. Thanks Michael

unfortunately, HPIA and the Softpaqs it relies on are not designed to handle priorities in installation except for specific requirements for any Softpaq that needs something loaded or available in the system