ryan-jan / MSCatalog

PowerShell module for searching and downloading offline updates from https://www.catalog.update.microsoft.com
MIT License
58 stars 16 forks source link

Improved Search - Better Matching #32

Closed hl2guide closed 9 months ago

hl2guide commented 10 months ago

I'm new to this module.

So far I have noticed that:

e.g.

Import-Module "MSCatalog"
$windows = "Windows 10"
$version = "22H2"
$month = "2023-09"
$textSearch = "$month Cumulative Update for $windows Version $version for x64-based Systems"
$textSearch
$searchResults = Get-MSCatalogUpdate -Search $textSearch -SortBy "Title" -Descending | `
# Where-Object -Property Products -Like "*Windows 10*" | `
Where-Object -Property Title -NotLike "*Preview*" | `
Where-Object -Property Title -NotLike "*Dynamic*"

$searchResults

returns a Windows 11 result?

Can we please have parameters for filtering "Products" and "Classification" for Get-MSCatalogUpdate?

makuhlmann commented 9 months ago

That's not an issue with the module, but just the behavior of the Microsoft Catalog search. However if you put search terms that consist of multiple words in quotes, it will respect them.

For example the search 2023-09 Cumulative Update for Windows 10 Version 22H2 for x64-based Systems returns 6 updates that match parts of the search query, but if you search for "2023-09 Cumulative Update for Windows 10 Version 22H2 for x64-based Systems" you will only get the one result you are looking for.

You can also add and exclude multiple individual search terms, for example if you want all cumulative, non dynamic updates for Windows 10 22H2 x64 of 2023, you can search for "Cumulative Update for Windows 10" "22H2" "2023-" "x64" -"Dynamic"

hl2guide commented 9 months ago

Cumulative Update for Windows 10" "22H2" "2023-" "x64" -"Dynamic

Thanks for reply for this but now I'm getting one search result but no Ids are listed when Save-MSCatalogUpdate is used.

Code:

# Download Windows Updates from the MSCatalog

Import-Module "MSCatalog"
$windows = "Windows 10"
$version = "22H2"
$year = "2023"
$month = "10"
$arch = "x64"
$languageLocale = "en-us"
#$textSearch = "$month Cumulative Update for $windows Version $version for x64-based Systems"
$textSearch = "`"$year`-$month Cumulative Update for $windows`" `"$version`" `"$arch`"" + `
" -`"Dynamic`" -`".NET`" -`"Preview`""
$textSearch

Write-Host "Searching MSCatalog for: $textSearch"
Write-Host

Get-MSCatalogUpdate -Search $textSearch -SortBy "Title" -Descending #| Save-MSCatalogUpdate -Destination ".\"
exit

Output:

Searching MSCatalog for: "2023-10 Cumulative Update for Windows 10" "22H2" "x64" -"Dynamic" -".NET" -"Preview"

Title                                                                                   Products                            Classification   LastUpdated Size
-----                                                                                   --------                            --------------   ----------- ----
2023-10 Cumulative Update for Windows 10 Version 22H2 for x64-based Systems (KB5031356) Windows 10,  version 1903 and later Security Updates 2023/10/10  767.8 MB

Id  FileName
--  --------
Multiple files exist for this update. Enter the Id of the file to download or 'A' to download all files.:
makuhlmann commented 9 months ago

Try to download the latest version of this module from Github, the version on the Powershell Gallery is a bit outdated and has issues like that.

Also small suggestion, you don't need to escape the quotation marks if you define your variable like this:

$textSearch = '"2023-10 Cumulative Update for Windows 10" "22H2" "x64" -"Dynamic" -".NET" -"Preview"'