While working on the Windows 10 upgrade project, I ran into a situation which I needed the information from an MSU file for the task sequence. Specifically, I needed the KB number. The first thing I did was to try and use the same method used in retrieving info from MSI and MSP files by trying to query the database. That does not work with an MSU file. An MSU is nothing more than a zipped up file of several files. In each MSU file, there is a *Properties.txt file which contains all of the info.
This script contains the function Get-MSUFileInfo which will retrieve all available info on the MSU. I designed it so that it creates an extracted folder in the relative path of the script. The MSU is then extracted to that extracted folder. Next, the script will read all of the contents of the *Properties.txt file into an object. Finally, the extracted folder is deleted.
Here is an example of the script retrieving the info into an object:
You can download the script which contains the function from my GitHub site. I put the function into a full script for easy testing in your environment.
The code as shown does not report the complete value for 'SupportLink' - it reports "http://support.microsoft.com?kbid", which should be "http://support.microsoft.com?kbid=958830".
ReplyDeleteA quick-and-dirty fix is to modify Line 66 to be:
$MSUObject | Add-Member -MemberType NoteProperty -Name SupportLink -Value ((Get-Content -Path $ExpandedFile.FullName | Where-Object { $_ -like '*Support Link*' }).split("=")[1].replace('"', '') + '=' + (Get-Content -Path $ExpandedFile.FullName | Where-Object { $_ -like '*Support Link*' }).split("=")[2].replace('"', '') ).
Probably more straight-forward ways, but this works.