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:
-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
Version 1.90
Modified behavior for maintaining additional softpaqs in .ADDSOFTWARE subfolder. The script will now create and maintain a list of required additional softpaqs for the reporitory in a flag file name for the platform ID. Each line in the flag file will be matched to an available softpaq for the model and OS version. If found it will be downloaded and then copied over to the main repository after each Sync... The additional softpaqs will then be available for HPIA when using /category:software in the execution. It assumes that for this to work as expected, the softpaqs listed in the flag file are of the Software category
The User Guide submitted to GitHub reflects the new use model
Version 1.91
Better support for the ability to maintain additional softpaqs (typically 'software' type, but any softpaq name will be matched) in the private .ADDSOFTWARE subfolder at each repository. The flag file, name as the 4 charatecer system ID of a platform contains names of softpaqs to download and make available to HPIA.
A new dialog allows the addition or removal of softpaqs by name in the subfolder
Version 2.00
Provide support for Windows 11. Note this requires the use of an updated version of the INI file. The updated INI file includes separate Win10 and Win11 OS versions to be allowed in the downloader script
Version 2.01
Fixed issue when browsing for an existing repository where it would not display model ID's correctly on the grid
Version 2.04.02
Added 'Remove Model' button and significant code update and cleanup