Installing the HP Client Management Script Library

If you’ve been keeping up with my blog posts, you’ll know that HP natively provides a few WMI classes and methods to the WIndows OS. These WMI classes work great for managing BIOS settings, but what if I want to manage Firmware updates or work with HP Softpaqs? One answer is to use the HP Client Management Script Library. The HP CMSL is a bundle of PowerShell modules created by HP for the purpose of managing HP firmware and drivers from the command line.

HP recently released the latest Client Management Script Library modules to the PowerShell gallery. I thought this provided a good opportunity to take a deeper look at what this tool offers. In this post I’ll be taking about the different ways to install the HP CSML.

If you’re just here for the script, you can find it on my GitHub: https://github.com/ConfigJon/Firmware-Management/blob/master/HP/Install-HPCMSL.ps1

Prerequisites

The only prerequisite for running the Client Management Script Library in full windows is PowerShell version 5.1 or newer. Before the CMSL can be run from WinPE, these components need to be added to the boot image.

  • Microsoft .NET (WinPE-NetFx)
  • Scripting (WinPE-Scripting)
  • Scripting (WinPE-WMI)
  • Windows PowerShell (WinPE-PowerShell)

The WinPE-Scripting and WinPE-WMI components are included in SCCM boot images by default. The WinPE-WMI and WinPE-PowerShell components need to be added in the Optional Components tab of the boot image Properties window.

Installation

There are 3 main ways to install the HP Client Management Script Library.

  • Install using the executable installer provided by HP
  • Install directly from the PowerShell gallery using Install-Module
  • Copy the CMSL module files into the PowerShell modules directory

Executable Install

HP provides an installer than can be run in a full Windows OS. The installer can be downloaded from HERE. The executable is an InnoSetup installer and will take any of the standard InnoSetup switches. A basic silent install of the executable would look like this.

hp-cmsl-latest.exe /VERYSILENT

PowerShell Gallery Install

HP has also made the Client Management Script Library modules available on the PowerShell gallery. This means that any computer with internet access can install the modules using the Install-Module PowerShell cmdlet.

#Install the HPCMSL modules and prompt for install and license agreement
Install-Module -Name HPCMSL

#Install the HPCMSL modules and suppress the install and license agreement prompts
Install-Module -Name HPCMSL -Force -AcceptLicense

This seems like all that should be required for the install. However there are a couple pre-requisites when installing directly from the PowerShell Gallery.

If you frequently install PowerShell modules on your system, these requirements may already be taken care of. However, on systems that haven’t installed modules from the PowerShell Gallery, both of these items will need updates.

If the current version of PowerShellGet is less than 2.0.1, there is a bug where after installing the latest version, a new PowerShell session needs to be opened to access the updated version.

File Copy Install

Both the executable install and the PowerShell Gallery install result in some files and folders being copied into Program Files\WindowsPowerShell\Modules. So instead of using one of those automated install options, the files could just be manually copied.

These are the folders that need to be copied.

These folders can be obtained in multiple ways. The HP Client Management Script Library could be installed on a machine using either the executable or Install-Module cmdlet. Then the files could be copied from Program Files\WindowsPowerShell\Modules. Alternatively, the files could be downloaded directly from the PowerShell Gallery.

Note that in order for the modules to be detected by PowerShell, they need to be correctly named. The folder name needs to be the same as the name of the module it contains.

This is the method that would need to be used when installing the HP Client Management Script Library in WinPE. This is because WinPE doesn’t support installing Modules directly from PowerShell Gallery and also does not allow for installing from an executable.

Install-HPCMSL.ps1

I decided to create a PowerShell script to automate the PowerShell Gallery and file copy install methods for the HP Client Management Script Library. The script can be run either in online mode or offline mode.

When running the script in online mode, it will reach out to the PowerShell Gallery and compare the version of the HPCMSL module against the locally installed version. If the PowerShell Gallery version is newer, it will be automatically downloaded and installed. The script also has logic to automatically install and update the NuGet Package Provider and the PowerShellGet module. Running the script in online mode requires a full Windows OS with internet access.

When running the script in offline mode, it will look for the HPCMSL modules in a local folder. The script will compare the versions of the modules in the folder against the currently installed versions. If the modules need to be updated, the new files will be copied.

The script has one optional parameter.

ModulePath – This parameter is used to specify the location of the HPCMSL module source files. If the parameter is specified the script will work in offline mode. Otherwise the script will run in online mode. This parameter should be specified when the script is running in WinPE or when the system does not have internet access.

Examples

Run the script in online mode

Install-HPCMSL.ps1

Run the script in offline mode

Install-HPCMSL.ps1 -ModulePath HPCMSL

IMPORTANT: When the script is running in offline mode, it is looking for a specific folder structure. Each of the HP Client Management Script Library modules need to be placed in the root of the folder specified in the ModulePath parameter. These folders need to be named exactly how they are named by HP.

  • HP.ClientManagement
  • HP.Firmware
  • HP.Private
  • HP.Repo
  • HP.Sinks
  • HP.Softpaq
  • HP.Utility
  • HPCMSL

Each one of these module folders should have a single first-level sub-folder. The name of this sub-folder should be the version of the included module. If the module files are obtained from a previous installation using either the executable or Install-Module, the folder structure will already be correct. If the module files are obtained directly from the PowerShell Gallery, this folder structure will need to be created.

In the above example, the script is called with the ModulePath parameter referencing a folder named HPCMSL. This folder is located in the same directory as the Install-HPCMSL.ps1 file. The HPCMSL folder then contains all of the properly named module folders, and each module folder contains a version sub-folder which then contains the actual module files.

This script can be run as part of a Configuration Manager task sequence to install the modules either in WinPE or the full Windows OS. The task sequence step would look like this:

Logging

The script will create a log file named Install-HPCMSL.log. When running outside of a task sequence, the log file will be located in ProgramData\BiosScripts\HP. When running inside of a task sequence, the log file will be located in the _SMSTSLogPath.

Additional Reading

I’m planning some future blog posts to cover the functionality of the HP Client Management Script Library. I’ll link to those posts here as they happen. For now, you can read more about using the HP Client Management Script Library in HP’s official documentation.