0
votes

I have a Nagios plugin https://outsideit.net/check-ms-win-updates/ which checks when the last WSUS was installed successfully. This is based on a string 'LastSuccessTime' in a registry key located here: 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\Results\Install'

   $LastSuccessTimeFolder = 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\Results\Install'
   $LastSuccessTimeValue = Get-ItemProperty -Path $LastSuccessTimeFolder -Name LastSuccessTime | Select-Object -ExpandProperty LastSuccessTime

This key is not available on Windows 10 it seems. So how can I get the LastSuccessTime date / time form a Windows 10 pc?

1
I know that but reading a registry key is so much faster then importing a module, running get-wuhistory and parsing the date from the latest update. Get-WUHistory | Select-Object -first 1 | Select -ExpandProperty "Date" - willemdh
Have you tried Windows Update Agent API? - lloyd
I'm using it actually in the script I mentioned in the post, but this is also very CPU intensive, that's why it uses a cachefile, so I only need to call it once every 24 hours. - willemdh
@willemdh Not to mention that there will be people like me coming through here who are looking for a way to get the last update date of an offline image where booting it up to run a powershell or VBScript module over it is definitely not a usable solution. - Perkins

1 Answers

0
votes

Not the best solution, but parsing out C:\Windows\Logs\WindowsUpdate will easily get you a list of the last times that updates were checked for.

Figuring out whether it was successful or not would require parsing the logs. How hard that would be depends on whether or not the "Exit code" at the end changes based on success or failure or not. Since I don't need that for my current purposes I'll leave it to some future expert to decipher.