Automating Maintenance of HP Image Assistant Repositories

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 -Force

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

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.