HP BCU to CMSL Part 2

Welcome back, in the first post HP DCU to HP CMSL I went over how you can use PowerShell to manage your BIOS settings, in this post we’ll dig a bit deeper into BCU configuration files, and how you can convert them to PowerShell. [ Script on GitHub ]

This would also be a great time to prune your config files and ensure you’re not setting things you don’t want to set. BCU default config files have EVERYTHING in them, so hopefully you’re removing the extra stuff and only setting what you need. In my examples, I have 2 config files, one that’s default, long and ugly, and one that I’ve removed a lot of extra stuff.

Let’s look at a BCU config file (BiosConfigUtility64.exe /get:”840G5.BCUConfig”)

You can see it starts with some basics then lists static information about the computer, all being pulled from the BIOS. Many of these things aren’t configurable, and read only.

From here, I like to delete a ton of that junk, and leave more of just things I want to set. I’ll leave the intro, just for reference, but I then clean up a lot of the settings.

So I’m assuming if you’re reading this, you already have a lot of BCU files and are a bit familiar with the layout.

You can see there are settings, values, and an * next to the selected value. With this consistent formatting of the config files, we can now go to PowerShell and build a PS Object from them.

I’m using a default export, and a cleaned up export from the same machine, probably not the best for a demo, but it’s what I have right now.

Getting the info from the Files… I’ll show the entire script, then start to break it down:

First, we read in the files into variables, and make sure each line is its own value by using -ReadCount 1, We then merge the variables into an array, so we can loop through, and create an empty array to stash data.

Now’ll we’ll go config file by config file ignoring lines that aren’t important. We also build another array to stash data from each config file that gets merged later. We’re going to null out variabels that get used along the way.

Now we get to the good stuff, we’re going to look for lines that aren’t indented by a tab (“`t”), and we know that if it’s not indented, then it’s the name of a setting, so we’ll create a variable called $SettingName and store that info. I also know that after the setting name, there will be the values of the setting, but since I don’t know how many options there are for the setting, I’m just going to grab the next ten lines in the config file and look at those.

In the next 10 lines, we’re only going to look at things that are indented and for items with *, if found, that’s the Value we want to record. We have to be careful, because if we fine a line that isn’t indented, then we know we’re already onto the next setting, so we’ll break. If the setting has no values set for it (items with * under it), then we’ll set the $SelectedValue to $null, and not bother to record this information at all.

Next we build the PS Object for this specific config file. If the is a assigned value associated with the Setting, we’ll record it, if not, move along.

Finally after it’s run through all of your files, it will clean up the data, removing duplicates, and creating a JSON version of the information

The next part of the script, will take that JSON information, and use it to create a PowerShell script file that will use CMSL commands to loop through the settings to set them.

Ok, so that’s pretty straight forward!

Running the script on my machine looks like:

Taking a look at the $Database Var shows:

The script created the HPBIOSSettings.PS1 file in my root of C:\ (you can modify)

Opening the script in ISE

Running the script on my HP Elitebook 840 G5