Accessing Lenovo BIOS Downloads (Part 1)

by Dec 21, 2021

In this mini-series we illustrate how you can automate the process of looking up vendor information. While this mini-series focuses on Lenovo and returns the current BIOS update URI for selected models, many of the techniques illustrated here can be reused in similar scenarios as well.

In part 1 we start by accessing the raw Lenovo information which is a static XML document publicly available in the internet.

Invoke-RestMethod downloads the raw XML content. Due to encoding issues, the first three bytes of the document are corrupted, so the script skips these using SubString(). The remainder is then converted to XML type, thus allowing you to access the information in the document:

# Lenovo information:
$Uri = 'https://download.lenovo.com/cdrt/td/catalogv2.xml'
# load as text:
$data = Invoke-RestMethod -Uri $Uri -UseBasicParsing
# remove first 3 bytes, convert rest to XML:
[xml]$realData = $data.Substring(3)

# choose Lenovo model
$model = $realData.ModelList.Model | Out-GridView -Title 'Choose Model' -OutputMode Single

# determine URL for BIOS download:
$result = [PSCustomObject]@{
  Model = $model.Name
  DownloadBIOS = $model.BIOS.'#text'
 
}

$result

When you run this script, a dialog opens and shows the different Lenovo notebook models (among other information in other columns). You can then pick a model, and the script returns a PSCustomObject with the notebook model name and the URI for its BIOS update.


Twitter This Tip! ReTweet this Tip!