Skip to content

Commit

Permalink
Improve update script (more similar to UWP package)
Browse files Browse the repository at this point in the history
  • Loading branch information
flcdrg committed Nov 4, 2023
1 parent 07e06cd commit bc4e6c2
Showing 1 changed file with 90 additions and 121 deletions.
211 changes: 90 additions & 121 deletions dellcommandupdate/update.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -20,97 +20,96 @@ function global:au_SearchReplace {
function global:au_GetLatest {
$compareVersion = [Version] "0.0.0.0"

$cabUrl = "https://downloads.dell.com/catalog/CatalogPC.cab"
$cabUrl = "https://downloads.dell.com/catalog/CatalogIndexPC.cab"
$downloadedFile = [IO.Path]::GetTempFileName()

$client = new-object System.Net.WebClient
$client.DownloadFile($cabUrl, $downloadedFile)

$xmlFile = [io.Path]::Combine([IO.Path]::GetTempPath(), "CatalogPC.xml")
$xmlFile = [io.Path]::Combine([IO.Path]::GetTempPath(), "CatalogIndexPC.xml")

& expand $downloadedFile $xmlFile

# <SoftwareComponent schemaVersion="2.0" identifier="5abea4d5-82fb-4d78-bf55-ac022ed3af20" packageID="DDVDP" releaseID="DDVDP" hashMD5="bd2a08db415991ab2b9605737d26a187" path="FOLDER05055451M/1/Dell-Command-Update_DDVDP_WIN_2.4.0_A00.EXE" dateTime="2018-06-27T18:26:44+00:00" releaseDate="June 27, 2018" vendorVersion="2.4.0" dellVersion="A00" packageType="LWXP" rebootRequired="false" size="99823472">
# <Name>
# <Display lang="en"><![CDATA[Dell Command | Update,2.4.0,A00]]></Display>
# </Name>
# <ComponentType value="APAC">
# <Display lang="en"><![CDATA[Application]]></Display>
# </ComponentType>
# <Description>
# <Display lang="en"><![CDATA[This Win 32 package provides the Dell Command | Update Application and is supported on OptiPlex, Venue Pro Tablet, Precision, XPS Notebook and Latitude models that are running the following Windows operating systems: Windows 7,Windows 8, Windows 8.1 and Windows 10.]]></Display>
# </Description>
# <Category value="SM">
# <Display lang="en"><![CDATA[OpenManage Systems Management]]></Display>
# </Category>
# <SupportedDevices>
# <Device componentID="23400" embedded="1">
# <Display lang="en"><![CDATA[Dell Command | Update]]></Display>
# </Device>
# </SupportedDevices>
# <?xml version="1.0" encoding="utf-16"?>
# <ManifestIndex baseLocation="downloads.dell.com" creationDateTime="2023-08-11T18:11:42+05:30" version="2023.08.11" baseLocationAccessProtocols="HTTPS" schemaVersion="3.0" xmlns="openmanage/cm/dm">
# <InventoryComponent inventoryCollectorType="COMPACT" schemaVersion="3.0" releaseID="08KW8" releaseDate="July 25,2023" vendorVersion="11.0.4.1" dellVersion="A00" osCode="WIN" path="FOLDER10345440M/1/InvColPC_11.0.4.1.exe" size="12000224">
# <Cryptography>
# <Hash algorithm="MD5">6cbad366dee820758c63a4822f59ea10</Hash>
# <Hash algorithm="SHA256">fd4fbc83532b78b8f3ce98af59bc4c65664e6d4623d85f855602e22dae93001f</Hash>
# <Hash algorithm="SHA1">cbb6bd4d7f1936ffa718ed564d62b7bf6e0266c1</Hash>
# </Cryptography>
# </InventoryComponent>
# <GroupManifest type="MTPDK" id="3686011a-5ab8-4e1c-89fe-109e2f11296b" latest="f58068ef-0fbe-4b97-8b0c-1a1489a4b1ba" eol="false" BKCCompliance="true" creationDateTime="2023-08-11T18:12:34+05:30">
# <Display lang="en"><![CDATA[ PDK Catalog for XPS Notebook 9530]]></Display>
# <SupportedSystems>
# <Brand key="53" prefix="XPSNOTEBOOK">
# <Display lang="en"><![CDATA[XPS Notebook]]></Display>
# <Model systemID="0BEB" systemIDType="BIOS">
# <Display lang="en"><![CDATA[9530]]></Display>
# </Model>
# </Brand>
# </SupportedSystems>
# <ManifestInformation id="f58068ef-0fbe-4b97-8b0c-1a1489a4b1ba" releaseID="YF49R" creationDateTime="2023-08-10T18:14:54+05:30" version="2023.08.10" path="FOLDER10470102M/1/XPS_Notebook_0BEB.cab" size="106720" inventoryCollectorType="COMPACT">
# <Cryptography>
# <Hash algorithm="MD5">8464b9c5a702b269017560eb5ae3b7fa</Hash>
# <Hash algorithm="SHA1">abfb5edc66ec09c860291c7efa81b2e47f616ed2</Hash>
# <Hash algorithm="SHA256">2df92f7f0bdad6293cced8b5e715f9fbfc2b86c9c6910c7b5bdbe245490842b1</Hash>
# </Cryptography>
# <Display lang="en"><![CDATA[ PDK Catalog for XPS Notebook 9530]]></Display>
# </ManifestInformation>
# </GroupManifest>

$f = [System.Xml.XmlReader]::create($xmlFile)
$ns = [System.Xml.Linq.XNamespace] "openmanage/cm/dm"

while ($f.read()) {
switch ($f.NodeType) {
([System.Xml.XmlNodeType]::Element) {
if ($f.Name -eq "SoftwareComponent") {
$e = [System.Xml.Linq.XElement]::ReadFrom($f)

if ($e.Element("SupportedDevices") -and $e.Element("SupportedDevices").Element("Device")) {

$componentID = $e.Element("SupportedDevices").Element("Device").Attribute("componentID").Value

if ($componentID -eq "23400") # This is the magic number for Dell Command Update
{
$newVersion = $e.Attribute("vendorVersion").Value
if ($compareVersion -lt ([version] $newVersion)) {
$version = $newVersion
# FOLDER04358530M/2/Systems-Management_Application_X79N4_WN32_2.3.1_A00_01.EXE
$url = "https://downloads.dell.com/" + $e.Attribute("path").Value
$description = $e.Element("Description").Element("Display").Value
$releaseNotes = $e.Element("ImportantInfo").Attribute("URL").Value

$checksum = $e.Attribute("hashMD5").Value
$checksumType = "md5"

$compareVersion = [version] $newVersion
}
}
if ($f.NodeType -eq [System.Xml.XmlNodeType]::Element) {
if ($f.Name -eq "GroupManifest") {
$e = [System.Xml.Linq.XElement]::ReadFrom($f)

if ($e.Element($ns + "SupportedSystems") -and $e.Element($ns + "SupportedSystems").Element($ns + "Brand") -and $e.Element($ns + "SupportedSystems").Element($ns + "Brand").Element($ns + "Model")) {

$systemID = $e.Element($ns + "SupportedSystems").Element($ns + "Brand").Element($ns + "Model").Attribute("systemID").Value

if ($systemID -eq "0BEB") { # This is the magic number for XPS 9530
$cabUrl = "https://downloads.dell.com/" + $e.Element($ns + "ManifestInformation").Attribute("path").Value
break
}
}
}
}

}
$f.Dispose()

$cabs = "https://downloads.dell.com/FOLDER08398967M/1/Latitude_0A36.cab", "https://downloads.dell.com/FOLDER10050879M/1/XPS_Notebook_0BEB.cab"
$downloadedFile = [IO.Path]::GetTempFileName()

$downloadedFile = Move-Item -Path $downloadedFile -Destination ([IO.Path]::ChangeExtension($downloadedFile, ".cab")) -Force -PassThru

foreach ($cabUrl in $cabs) {
$downloadedFile = [IO.Path]::GetTempFileName()
$client = new-object System.Net.WebClient
$client.DownloadFile($cabUrl, $downloadedFile)

$client = new-object System.Net.WebClient
$client.DownloadFile($cabUrl, $downloadedFile)
$tempFolder = New-Item -ItemType Directory ([IO.Path]::Combine([IO.Path]::GetTempPath(), [IO.Path]::GetRandomFileName()))

$xmlFile = [io.Path]::Combine([IO.Path]::GetTempPath(), "CatalogPC.xml")
& expand -R $downloadedFile $tempFolder

& expand $downloadedFile $xmlFile
$xmlFile = Get-ChildItem $tempFolder -Filter *.xml -Recurse -File | Select-Object -First 1

# <SoftwareComponent schemaVersion="3.0" releaseID="W4HP2" releaseDate="April 01, 2022" vendorVersion="4.5.0" dellVersion="A00" packageType="LWXP" path="FOLDER08334841M/4/Dell-Command-Update-Application_W4HP2_WIN_4.5.0_A00_02.EXE" packageID="W4HP2" dateTime="2022-01-06T13:13:39+05:30" size="31297992" identifier="ac083258-cc0c-4dda-9318-21d5836e262b">
# <SoftwareComponent schemaVersion="3.0" releaseID="601KT" releaseDate="April 01, 2022" vendorVersion="4.5.0" dellVersion="A00" packageType="LWXP" path="FOLDER08334704M/2/Dell-Command-Update-Windows-Universal-Application_601KT_WIN_4.5.0_A00_01.EXE" packageID="601KT" dateTime="2022-01-06T13:10:24+05:30" size="33455904" identifier="df2cb539-010a-43d5-9485-9a8556fc3f11">
# <Name>
# <Display lang="en"><![CDATA[Dell Command | Update Application]]></Display>
# <Display lang="en"><![CDATA[Dell Command | Update Windows Universal Application]]></Display>
# </Name>
# <ComponentType value="APAC">
# <Display lang="en"><![CDATA[Application]]></Display>
# </ComponentType>
# <Description>
# <Display lang="en"><![CDATA[This package contains the Dell Command | Update application. Dell Command Update is a stand-alone application for client systems, that provides updates for system software that is released by Dell. This application simplifies the BIOS, firmware, driver, and application update experience for Dell client hardware.]]></Display>
# <Display lang="en"><![CDATA[This package contains the Dell Command | Update Windows Universal application. Dell Command Update is a stand-alone application for client systems, that provides updates for system software that is released by Dell. This application simplifies the BIOS, firmware, driver, and application update experience for Dell client hardware. This package is compatible only with Windows 10 Anniversary Update (Redstone 1) or later, and Windows 11 operating system.]]></Display>
# </Description>
# <Category value="SM">
# <Display lang="en"><![CDATA[Systems Management]]></Display>
# </Category>
# <SupportedDevices>
# <Device componentID="23400" embedded="false">
# <Device componentID="107174" embedded="false">
# <Display><![CDATA[Dell Command | Update]]></Display>
# </Device>
# </SupportedDevices>
Expand All @@ -123,114 +122,84 @@ function global:au_GetLatest {
# </Brand>
# </SupportedSystems>
# <SupportedOperatingSystems>
# <OperatingSystem osCode="W10P2" osVendor="Microsoft" osArch="x86" majorVersion="10" minorVersion="0" spMajorVersion="0" spMinorVersion="0">
# <Display lang="en"><![CDATA[Windows 10 32-Bit]]></Display>
# </OperatingSystem>
# <OperatingSystem osCode="W21H4" osVendor="Microsoft" osArch="x64" majorVersion="10" minorVersion="0" spMajorVersion="0" spMinorVersion="0">
# <Display lang="en"><![CDATA[Windows 11]]></Display>
# </OperatingSystem>
# <OperatingSystem osCode="W10P4" osVendor="Microsoft" osArch="x64" majorVersion="10" minorVersion="0" spMajorVersion="0" spMinorVersion="0">
# <Display lang="en"><![CDATA[Windows 10 64-Bit]]></Display>
# </OperatingSystem>
# <OperatingSystem osCode="WB32" osVendor="Microsoft" osArch="x86" majorVersion="6" minorVersion="3" spMajorVersion="0" spMinorVersion="0">
# <Display lang="en"><![CDATA[Windows 8.1 32-bit]]></Display>
# <OperatingSystem osCode="W10H2" osVendor="Microsoft" osArch="x86" majorVersion="10" minorVersion="0" spMajorVersion="0" spMinorVersion="0">
# <Display lang="en"><![CDATA[Windows 10 32-Bit]]></Display>
# </OperatingSystem>
# <OperatingSystem osCode="IOTL3" osVendor="Microsoft" osArch="x64" majorVersion="10" minorVersion="0" spMajorVersion="0" spMinorVersion="0">
# <Display lang="en"><![CDATA[Windows 10 64-Bit]]></Display>
# </OperatingSystem>
# <OperatingSystem osCode="W7H32" osVendor="Microsoft" osArch="x86" majorVersion="6" minorVersion="1" spMajorVersion="0" spMinorVersion="0">
# <Display lang="en"><![CDATA[Windows 7 32-bit]]></Display>
# </OperatingSystem>
# <OperatingSystem osCode="WB64" osVendor="Microsoft" osArch="x64" majorVersion="6" minorVersion="3" spMajorVersion="0" spMinorVersion="0">
# <Display lang="en"><![CDATA[Windows 8.1 64-bit]]></Display>
# <OperatingSystem osCode="W21P4" osVendor="Microsoft" osArch="x64" majorVersion="10" minorVersion="0" spMajorVersion="0" spMinorVersion="0">
# <Display lang="en"><![CDATA[Windows 11]]></Display>
# </OperatingSystem>
# <OperatingSystem osCode="WEL16" osVendor="Microsoft" osArch="x64" majorVersion="10" minorVersion="0" spMajorVersion="0" spMinorVersion="0">
# <Display lang="en"><![CDATA[Windows 10 64-Bit]]></Display>
# </OperatingSystem>
# <OperatingSystem osCode="W7HP6" osVendor="Microsoft" osArch="x64" majorVersion="6" minorVersion="1" spMajorVersion="0" spMinorVersion="0">
# <Display lang="en"><![CDATA[Windows 7 64-bit]]></Display>
# </OperatingSystem>
# <OperatingSystem osCode="W7Pr6" osVendor="Microsoft" osArch="x64" majorVersion="6" minorVersion="1" spMajorVersion="0" spMinorVersion="0">
# <Display lang="en"><![CDATA[Windows 7 64-bit]]></Display>
# </OperatingSystem>
# <OperatingSystem osCode="W7P32" osVendor="Microsoft" osArch="x86" majorVersion="6" minorVersion="1" spMajorVersion="0" spMinorVersion="0">
# <Display lang="en"><![CDATA[Windows 7 32-bit]]></Display>
# </OperatingSystem>
# <OperatingSystem osCode="W10H2" osVendor="Microsoft" osArch="x86" majorVersion="10" minorVersion="0" spMajorVersion="0" spMinorVersion="0">
# <Display lang="en"><![CDATA[Windows 10 32-Bit]]></Display>
# </OperatingSystem>
# <OperatingSystem osCode="W7HP3" osVendor="Microsoft" osArch="x86" majorVersion="6" minorVersion="1" spMajorVersion="0" spMinorVersion="0">
# <Display lang="en"><![CDATA[Windows 7 32-bit]]></Display>
# </OperatingSystem>
# <OperatingSystem osCode="W21H4" osVendor="Microsoft" osArch="x64" majorVersion="10" minorVersion="0" spMajorVersion="0" spMinorVersion="0">
# <Display lang="en"><![CDATA[Windows 11]]></Display>
# </OperatingSystem>
# <OperatingSystem osCode="IOT01" osVendor="Microsoft" osArch="x64" majorVersion="10" minorVersion="0" spMajorVersion="0" spMinorVersion="0">
# <Display lang="en"><![CDATA[Windows 10 64-Bit]]></Display>
# </OperatingSystem>
# <OperatingSystem osCode="WB32P" osVendor="Microsoft" osArch="x86" majorVersion="6" minorVersion="3" spMajorVersion="0" spMinorVersion="0">
# <Display lang="en"><![CDATA[Windows 8.1 32-bit]]></Display>
# </OperatingSystem>
# <OperatingSystem osCode="W10P2" osVendor="Microsoft" osArch="x86" majorVersion="10" minorVersion="0" spMajorVersion="0" spMinorVersion="0">
# <Display lang="en"><![CDATA[Windows 10 32-Bit]]></Display>
# </OperatingSystem>
# <OperatingSystem osCode="W21P4" osVendor="Microsoft" osArch="x64" majorVersion="10" minorVersion="0" spMajorVersion="0" spMinorVersion="0">
# <Display lang="en"><![CDATA[Windows 11]]></Display>
# </OperatingSystem>
# <OperatingSystem osCode="W7H64" osVendor="Microsoft" osArch="x64" majorVersion="6" minorVersion="1" spMajorVersion="0" spMinorVersion="0">
# <Display lang="en"><![CDATA[Windows 7 64-bit]]></Display>
# </OperatingSystem>
# <OperatingSystem osCode="W10H4" osVendor="Microsoft" osArch="x64" majorVersion="10" minorVersion="0" spMajorVersion="0" spMinorVersion="0">
# <Display lang="en"><![CDATA[Windows 10 64-Bit]]></Display>
# </OperatingSystem>
# </SupportedOperatingSystems>
# <ImportantInfo URL="https://www.dell.com/support/home/us/en/19/Drivers/DriversDetails?driverId=W4HP2">
# <ImportantInfo URL="https://www.dell.com/support/home/us/en/19/Drivers/DriversDetails?driverId=601KT">
# <Display lang="en"><![CDATA[NA]]></Display>
# </ImportantInfo>
# <Criticality value="1">
# <Display lang="en"><![CDATA[Recommended]]></Display>
# </Criticality>
# <Cryptography>
# <Hash algorithm="MD5">5f199e6770b8477f4d095db3dee222a1</Hash>
# <Hash algorithm="SHA256">c090c94dc313b26415effb508f904e45e36b1833023ab86c76c49150d3d520f9</Hash>
# <Hash algorithm="SHA1">021d63d4fe018b5cc8e6a39d92feb3a0be63b8c7</Hash>
# <Hash algorithm="MD5">ab4b460cb8d831481e8ab6817589effa</Hash>
# <Hash algorithm="SHA256">a032355d5ac396ed28903a72345744857e40b52faadf0b4f6dc9c81d4e5f535f</Hash>
# <Hash algorithm="SHA1">f5de7eedc9c0b90df1e2ddd57fc0050c6d4a34a9</Hash>
# </Cryptography>
# <SharedModules>
# <SharedModule moduleID="107714" />
# </SharedModules>
# </SoftwareComponent>

$f = [System.Xml.XmlReader]::create($xmlFile)
$f = [System.Xml.XmlReader]::create($xmlFile)

while ($f.read()) {
switch ($f.NodeType) {
([System.Xml.XmlNodeType]::Element) {
if ($f.Name -eq "SoftwareComponent") {
$e = [System.Xml.Linq.XElement]::ReadFrom($f)
while ($f.read()) {
if ($f.NodeType -eq [System.Xml.XmlNodeType]::Element) {
if ($f.Name -eq "SoftwareComponent") {
$e = [System.Xml.Linq.XElement]::ReadFrom($f)

$ns = [System.Xml.Linq.XNamespace] "openmanage/cm/dm"
$ns = [System.Xml.Linq.XNamespace] "openmanage/cm/dm"

if ($e.Element($ns + "SupportedDevices") -and $e.Element($ns + "SupportedDevices").Element($ns + "Device")) {
if ($e.Element($ns + "SupportedDevices") -and $e.Element($ns + "SupportedDevices").Element($ns + "Device")) {

$componentID = $e.Element($ns + "SupportedDevices").Element($ns + "Device").Attribute("componentID").Value
$componentID = $e.Element($ns + "SupportedDevices").Element($ns + "Device").Attribute("componentID").Value

if ($componentID -eq "23400") { # This is the magic number for Dell Command Update
$newVersion = $e.Attribute("vendorVersion").Value
if ($compareVersion -lt ([version] $newVersion)) {
$version = $newVersion
# FOLDER04358530M/2/Systems-Management_Application_X79N4_WN32_2.3.1_A00_01.EXE
$url = "https://downloads.dell.com/" + $e.Attribute("path").Value
$description = $e.Element($ns + "Description").Element($ns + "Display").Value
$releaseNotes = $e.Element($ns + "ImportantInfo").Attribute("URL").Value
if ($componentID -eq "23400") { # This is the magic number for Dell Command Update
$newVersion = $e.Attribute("vendorVersion").Value
if ($compareVersion -lt ([version] $newVersion)) {
$version = $newVersion
# FOLDER04358530M/2/Systems-Management_Application_X79N4_WN32_2.3.1_A00_01.EXE
$url = "https://downloads.dell.com/" + $e.Attribute("path").Value
$description = $e.Element($ns + "Description").Element($ns + "Display").Value
$releaseNotes = $e.Element($ns + "ImportantInfo").Attribute("URL").Value

# schemaVersion 3.0
$checksum = ($e.Element($ns + "Cryptography").Elements() | Where-Object { $_.Attribute("algorithm").Value -eq "SHA256" }).Value
$checksumType = "sha256"
# schemaVersion 3.0
$checksum = ($e.Element($ns + "Cryptography").Elements() | Where-Object { $_.Attribute("algorithm").Value -eq "SHA256" }).Value
$checksumType = "sha256"

$compareVersion = [version] $newVersion
}
}
$compareVersion = [version] $newVersion
}
}
}
}
}
$f.Dispose()
}
$f.Dispose()

$Latest = @{
URL32 = $url
Expand Down

0 comments on commit bc4e6c2

Please sign in to comment.