Don't you love it when your application works on one machine, but not the other? We were running into this exact issue with a client and needed to see what was different between the operating systems on two machines. Thinking that the issue might have been a problem that got fixed in a hotfix/service pack, I whipped up the following PowerShell commands to get you the OS updates. I thought I'd share mainly so I wouldn't have to figure out how to write this again six months from now.
$updateSearcher = new-object -com "Microsoft.Update.Searcher"
$updateCount= $updateSearcher.GetTotalHistoryCount()
$updateSearcher.QueryHistory(0,$updateCount) | Sort-Object -Property Date | ForEach-Object { Write-Output $_.Date $_.Title }
Edit: Sept. 10, 2010: Thanks for the comments, <blush>, I used the wrong variable name. All fixed now.
On Sep 9 2010 2:03 PMBy jrobbins
should $totalupdates on line 3 be $updateCount?
I get the following error when I run that:
Exception calling "QueryHistory" with "2" argument(s): "Exception from HRESULT: 0x80240007"
At line:1 char:29
+ $updateSearcher.QueryHistory
May I recommend instead for that last line:
$updateSearcher.QueryHistory(0,$updateCount) | Sort-Object -Property Date | Select-Object Date,Title
The last line should have been the following:
$updateSearcher.QueryHistory(0,$updateCount) | Sort-Object -Property Date | ForEach-Object { Write-Output $_.Date $_.Title }
where $totalUpdates are replaced by $updateCount
>Don't you love it when your application works on one machine, but not the other?
A few months ago I wrote about all sorts of identified problems we had concerning that: Windows programming: The "it works on my machine" syndroma
http://codebetter.com/blogs/patricksmacchia/archive/2010/04/06/windows-programming-the-quot-it-works-on-my-machine-quot-syndroma.aspx
Hello,
nice script but there's a mistake:
$updateSearcher.QueryHistory(0,$totalupdates) | Sort-Object -Property Date | ForEach-Object { Write-Output $_.Date $_.Title }
=> should use $updateCount instead of $totalUpdates
Is it $updateCount or $totalupdates?
Nice! One minor nitpick: in line 2 you're assigning to $updateCount, but in line 3 you're referring to it as $totalupdates.
You need to change $totalupdates to $updateCount in the last line.
I think you mean $updateSearcher.QueryHistory(0,$updateCount), not $totalupdates
on 2008 R2 I get the error message the same as Dave.
Exception calling "QueryHistory" with "2" argument(s): "Exception from HRESULT: 0x80240007"
Anyone got any ideas?