From f99730b471d82d9b862b314d9a0fbee03fdfe9e0 Mon Sep 17 00:00:00 2001 From: Lu Yang Date: Fri, 8 Sep 2023 16:53:36 -0700 Subject: [PATCH 1/2] Fix Get-LatestSurfaceEthernetDrivers --- CreateSurfaceWindowsImage.ps1 | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/CreateSurfaceWindowsImage.ps1 b/CreateSurfaceWindowsImage.ps1 index 29b71f6..daf1fb8 100644 --- a/CreateSurfaceWindowsImage.ps1 +++ b/CreateSurfaceWindowsImage.ps1 @@ -1202,7 +1202,7 @@ Function Get-LatestSurfaceEthernetDrivers } Else { - $URI = 'https://www.catalog.update.microsoft.com/Search.aspx?q=Realtek - Net - 10.45.0308.2021' + $URI = "http://www.catalog.update.microsoft.com/Search.aspx?q=Realtek - Net - 10." $kbObj = Invoke-WebRequest -Uri $uri -UseBasicParsing # Parse the Response @@ -1217,27 +1217,28 @@ Function Get-LatestSurfaceEthernetDrivers # Initialize array, get title and GUID of update $guids = $null $guids = @() - foreach ($kbObjectsLink in $kbObjectsLinks) + ForEach ($kbObjectsLink in $kbObjectsLinks) { $itemguid = $kbObjectsLink.id.replace('_link', '') $itemtitle = ($kbObjectsLink.outerHTML -replace '<[^>]+>', '').Trim() - if ($itemguid -in $kbObjects) { + If ($itemguid -in $kbObjects) + { $guids += [pscustomobject]@{ guid = $itemguid description = $itemtitle } } } - + # Return a hard-coded array member for now until this settles out - changeover from "Surface - NET" to "Realtek - Net" causes issues with # of returns and version info changes - #$global:KBGUID = $guids | Where-Object {($_.description -like "*Realtek - Net - 10.45.0308.2021*")} + #$global:KBGUID = $guids | Where-Object {($_.description -like "*Realtek - Net - 10.*")} $global:KBGUID = $guids[0] $scriptblock = { $guid = $_.Guid $itemtitle = $_.description - $guid - + #$guid + $post = @{ size = 0; updateID = $guid; uidInfo = $guid } | ConvertTo-Json -Compress $body = @{ updateIDs = "[$post]" } Invoke-WebRequest -Uri 'https://www.catalog.update.microsoft.com/DownloadDialog.aspx' -Method Post -Body $body | Select-Object -ExpandProperty Content @@ -1258,16 +1259,22 @@ Function Get-LatestSurfaceEthernetDrivers $downloaddialog = $downloaddialog.Replace('www.download.windowsupdate', 'download.windowsupdate') $DLWUDOTCOM = ($downloaddialog | Select-String -AllMatches -Pattern "(http[s]?\://download\.windowsupdate\.com\/[^\'\""]*)" | Select-Object -Unique | ForEach-Object { [PSCustomObject] @{ Source = $_.matches.value } } ).source $DLDELDOTCOM = ($downloaddialog | Select-String -AllMatches -Pattern "(http[s]?\://dl\.delivery\.mp\.microsoft\.com\/[^\'\""]*)" | Select-Object -Unique | ForEach-Object { [PSCustomObject] @{ Source = $_.matches.value } } ).source + $DLCATALOGDOTCOM = ($downloaddialog | Select-String -AllMatches -Pattern "(http[s]?\://catalog\.s\.download\.windowsupdate\.com\/[^\'\""]*)" | Select-Object -Unique | ForEach-Object { [PSCustomObject] @{ Source = $_.matches.value } } ).source If ($DLWUDOTCOM) { - "URL: $link" + "URL: $link" $links = $DLWUDOTCOM } If ($DLDELDOTCOM) { $links = $DLDELDOTCOM } + If ($DLCATALOGDOTCOM) + { + $links = $DLCATALOGDOTCOM + } + If ($links) { From 5515f7ec4f23736e968b619d96e5494fd457ca15 Mon Sep 17 00:00:00 2001 From: Lu Yang Date: Fri, 8 Sep 2023 16:55:28 -0700 Subject: [PATCH 2/2] minor changes --- CreateSurfaceWindowsImage.ps1 | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/CreateSurfaceWindowsImage.ps1 b/CreateSurfaceWindowsImage.ps1 index daf1fb8..6c2ace9 100644 --- a/CreateSurfaceWindowsImage.ps1 +++ b/CreateSurfaceWindowsImage.ps1 @@ -1202,7 +1202,7 @@ Function Get-LatestSurfaceEthernetDrivers } Else { - $URI = "http://www.catalog.update.microsoft.com/Search.aspx?q=Realtek - Net - 10." + $URI = "https://www.catalog.update.microsoft.com/Search.aspx?q=Realtek - Net - 10." $kbObj = Invoke-WebRequest -Uri $uri -UseBasicParsing # Parse the Response @@ -1237,7 +1237,6 @@ Function Get-LatestSurfaceEthernetDrivers $scriptblock = { $guid = $_.Guid $itemtitle = $_.description - #$guid $post = @{ size = 0; updateID = $guid; uidInfo = $guid } | ConvertTo-Json -Compress $body = @{ updateIDs = "[$post]" }