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

Implement "SortBy" parameter and improve "Strict" parameter behaviour. #7

Closed ryan-jan closed 3 years ago

ryan-jan commented 3 years ago

Following discussion in #6 it was decided that to improve performance, and provide the maximum flexibility, the Get-MSCatalogUpdate command would be refactored to implement a SortBy parameter. This parameter sorts the results by issuing POST requests to the catalog.update.microsoft.com site. This performs much better than pulling all results using the AllPages parameter and then sorting using the native Sort-Object PowerShell command, which is currently the only way to sort the results.

As well as the SortBy parameter I have also improved the Strict parameter. Previously, when using the Strict parameter without the AllPages parameter, the first page of 25 results were returned from the catalog.update.microsoft.com site and then we were filtering out any results which did not strictly match the search term. This was confusing to the end user as it could appear, incorrectly, that there were no more results to fetch (for example if there were only 4 strict matches in the first page of 25 results). In order to make this behave a bit more as expected, if you now issue the Strict parameter without the AllPages parameter the command will continue to request results from the catalog.update.microsoft.com site and filter them by the strict search term until there are 25 results to display (unless there are fewer than 25 results in total).

I have also implemented classes for both the catalog.update.microsoft.com site response object and this module's main MSCatalogUpdate object which enabled me to refactor the code to be more efficient and easier to read.