If you've been following my blog, you know I often write about the environments I manage for demo purposes. I definitely cut corners and don't always build things with the "enterprise" in mind. In my opinion, there are always better ways of doing what I'm doing, but I also post about what I'm doing in the event it helps people understand tech better or how to craft out automated ways of managing infrastructure.
In one of my environments, I deployed WSUS. I know...the dreaded WSUS. Why would I even deal with that after all these automated tools and better ways to patch exist? Well, I always wonder what customers are doing, so some of my environments have things deployed like WSUS so I don't lose that skill.
1 thing that has always been a little tough is when my servers automatically update and it takes WSUS a long time to show every server as 100% patched (even with wuauclt /detectnow and wuauclt /reportnow). I located a blog post that gave me fuel to craft out something to use within my environment if I couldn't get servers to register as 100% patched in a fast fashion. Check out that blog post here. The big piece of code that consistently worked for me is as follows:
$updateSession = New-Object -com "Microsoft.Update.Session"; ` $updates=$updateSession.CreateupdateSearcher().Search($criteria).Updates
wuauclt.exe /reportnow
I tested this script out a few months in a row on each server individually and it worked as expected. All servers I maintain in my WSUS environment show as patched!
But doing this 1 server at a time is tedious and time consuming. So, I did what any PowerShell heavy user would do: I automated this for my environment, and it's been working for all servers in one fell swoop. What does the code look like? Take a peek at the script on GitHub and then here's what the script looks in practice:
I'm not positive this will 100% help you out in your environment, but in the chance it does, hopefully this blog post gives you some direction to travel if this problem is sometimes plaguing you in your environment. If you have any questions, feel free to reach out or reply to this post. Thanks for reading!