Comments (12)
That's very cool Ryan! I was pretty sure that the issue is on catalog side of things, rather than your code of pulling it. I just wanted to see if you know of any shortcuts... :)
The "$((Get-Date).ToString('yyyy-MM'))
trick is nifty and works starting every patch tuesday - It's just really inelegant. I wish microsoft would expose a better API to their update catalog site, at least &product=&sortby=
Either way, big thanks for implementing this module. It saves a lot of manual grief.
from mscatalog.
Hi, thanks for taking the time to use this module, and thanks for your feedback! Unfortunately, the issue you describe is due to the way in which the catalog.update.microsoft.com site returns the updates from the search term. If you go to catalog.update.microsoft.com in a web browser and search for Cumulative Update for Windows Server 2019 for x64-based Systems
you will see that you also do not get the latest update on the first page of results (only the latest preview) and you would need to sort the table by the Last Updated
field in order to see the latest Cumulative Update for Windows Server 2019 for x64-based Systems
update. With most search engines you could wrap your search string in quotes to tell the search engine to match the exact string, which would help in this scenario. However, for some reason, the catalog.update.microsoft.com search function does not behave in this way. If you try it in your browser you should see exactly the same results with or without quotes.
The Strict
parameter of this module simply filters the results returned from catalog.update.microsoft.com in PowerShell to try and help with this short-coming of the catalog sites functionality. But, as you have found, this means you do need to also apply the AllPages
parameter which is far from ideal as it can make multiple requests to the catalog and is time consuming.
In your particular scenario of downloading the latest update, it is actually very trivial to include the YYYY-MM in the search string dynamically, which should limit the search results sufficiently to be able to use the Strict
parameter without the AllPages
parameter. This should achieve what you are looking for and is actually how I have my automation set up in my day job. So, you could do the following to get the latest update for this month, assuming one has been released.
Get-MSCatalogUpdate "$((Get-Date).ToString('yyyy-MM')) Cumulative Update for Windows Server 2019 for x64-based Systems" -Strict
Title Products Classification LastUpdated Size
----- -------- -------------- ----------- ----
2020-10 Cumulative Update for Windows Server 2019 for x64-based Systems (KB4577668) Windows Server 2019 Security Updates 2020/10/12 368.3 MB
If one has not been released this will just return a warning saying WARNING: We did not find any results for xyz
Please let me know if this helps with you particular issue, and if so I will close this off.
from mscatalog.
I have investigated this further and, while my previous comment is accurate and the workaround should help you, I have also worked out how to sort the results directly from the catalog site by any field in the table (e.g. Title, Products, LastUpdated etc.). Therefore, I have begun work on a pull request to implement a SortBy
paramater for the Get-MSCatalogUpdates
command. This will take me some time but will eventually enable greater flexibility in retrieving results from the catalog site without the need to include the AllPages
switch, which as we have already mentioned is not great from a performance point of view. I will update this issue with progress.
from mscatalog.
@umaritimus I have implemented a SortBy
parameter and improved the Strict
parameter in the branch feature/improve-sorting-and-strict-results
. Would you be interested in testing this out and giving some feedback?
The two changes are:
SortBy
parameter implemented forGet-MSCatalogUpdate
allowing sorting by specific column. The default sort is now by LastUpdated and in descending order which is what I think will help you with your original issue.- The
Strict
parameter has now been tweaked to always show 25 results even if this means making a couple of extra calls to the catalog site. This just makes it behave a bit more as I think users would expect it to. If you useStrict
withAllPages
then obviously more results will be returned.
from mscatalog.
Sure... Is it already in PSGallery?
from mscatalog.
No, I was thinking you could just pull down the branch with git clone and import the MSCatalog.psd1 file in the MSCatalog directory for a quick test.
from mscatalog.
K, let me see what i can do - it might take me couple days - i need to prep a test machine, but i also found this - Quickly Install PowerShell Modules from GitHub 😃
from mscatalog.
Works marvelously!
Get-MSCatalogUpdate -Search 'Cumulative Update for Windows Server 2019 for x64-based Systems' -Strict -SortBy Title -Descending
results in
Title Products Classification LastUpdated Size
----- -------- -------------- ----------- ----
2020-10 Cumulative Update for Windows Server 2019 for x64-based Systems (KB4577668) Windows Server 2019 Security Updates 2020/10/12 368.3 MB
2020-09 Cumulative Update for Windows Server 2019 for x64-based Systems (KB4570333) Windows Server 2019 Security Updates 2020/09/07 349.8 MB
2020-08 Cumulative Update for Windows Server 2019 for x64-based Systems (KB4565349) Windows Server 2019 Security Updates 2020/08/10 338.1 MB
2020-07 Cumulative Update for Windows Server 2019 for x64-based Systems (KB4558998) Windows Server 2019 Security Updates 2020/07/13 334.8 MB
2020-06 Cumulative Update for Windows Server 2019 for x64-based Systems (KB4567513) Windows Server 2019 Updates 2020/06/15 332.6 MB
2020-06 Cumulative Update for Windows Server 2019 for x64-based Systems (KB4561608) Windows Server 2019 Security Updates 2020/06/08 332.6 MB
...
from mscatalog.
Sorry it took me a while to test it out - I have limited VMs at my disposal, so I had to blow away one of my testing machines, but this amusing concoction of InstallModuleFromGitHub
does work rather well. 😃
Install-Module -Name InstallModuleFromGitHub
Install-ModuleFromGitHub -GitHubRepo ryan-jan/MSCatalog -Branch feature/improve-sorting-and-strict-results
Get-MSCatalogUpdate -Search 'Cumulative Update for Windows Server 2019 for x64-based Systems' -Strict
The speed improved significantly too without the AllPages
flag - awesome work! Please merge!
from mscatalog.
Glad it is working for you. It will take a little bit longer to merge as I need to update the Pester tests etc seeing as I changed quite a bit of the code base in the end. Once it is done I will update this issue before closing.
from mscatalog.
Closing issue as these changes have now been merged with master and have been pushed to PowerShell gallery. Run Update-Module MSCatalog
to pull the latest version from the gallery.
from mscatalog.
Excellent work!
from mscatalog.
Related Issues (20)
- Invoke-WebRequest : The underlying connection was closed: An unexpected error occurred on a send. HOT 1
- Get-MSCatalogUpdate -Search with PNPDeviceID does not work correctly HOT 2
- Set-TempSecurityProtocol and TLS 1.3
- Save-MSCatalogUpdate and updates with multiple files
- Save-MSCatalogUpdate - Unable to download anything HOT 1
- Search not working as expected HOT 2
- New maintainer HOT 4
- Allow downloading of all files matching the filter regex
- Get-MSCatalogUp[date search filtering HOT 3
- Download URLs have changed again HOT 1
- Saving Driver updates where there are many from the same version HOT 2
- -strict paramter stopped working HOT 3
- Feature add
- Publish to PowerShellGallery HOT 1
- Save-MSCatalog issue HOT 19
- Get-MSCatalogUpdate limited to 1000 results (even with -AllPages flag) HOT 1
- Improved Search - Better Matching HOT 3
- Get-UpdateLinks Regex not working HOT 1
- core functionality broken HOT 1
- downloading newer files (Windows 11) doesn't work HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mscatalog.