Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Question
Wednesday, April 8, 2015 4:53 AM
Hi all how to find the updates installed in 2003 and 8.. wimc qfe didnt give the exact output as what i see in updates installed in my system... found the below code but is not working 2003 and 8 os...
$Session = New-Object -ComObject "Microsoft.Update.Session"
$Searcher = $Session.CreateUpdateSearcher()
$historyCount = $Searcher.GetTotalHistoryCount()
$b = $Searcher.QueryHistory(0, $historyCount) | Select-Object Date,Title,
@{name="Operation"; expression={switch($_.operation){
- {"Installation"}; 2 {"Uninstallation"}; 3 {"Other"}}}},
@{name="Status"; expression={switch($_.resultcode){
{"In Progress"}; 2 {"Succeeded"}; 3 {"Succeeded With Errors"};
{"Failed"}; 5 {"Aborted"}
Can some one help me in getting the exact out put for 2003 & 8
- Delete
- 7 minutes ago
All replies (7)
Wednesday, April 8, 2015 7:57 PM ✅Answered | 2 votes
The code posted has many, many errors:
$operation=@('Unk','Installation','Uninstallation','Other')
$resultCode=@('Unk','In Progress','Succeeded','Succeeded With Errors','Failed','Aborted')
$updateSession=New-Object -ComObject Microsoft.Update.Session
$updateSearcher=$updateSession.CreateUpdateSearcher()
$historyCount=$updateSearcher.GetTotalHistoryCount()
$updateSearcher.QueryHistory(0, $historyCount) |
Select-Object Date,
@{N='Operation';E={$operation[$_.operation]}},
@{N='Status';E={$resultCode[$_.resultcode]}},
Title |
Format-Table -AutoSize
\(ツ)_/
Wednesday, April 8, 2015 5:10 AM
Hi There,
The code you've pasted seems to be a little bit messed up. I've corrected and tested it and it seems to work OK:
$Session = New-Object -ComObject "Microsoft.Update.Session"
$Searcher = $Session.CreateUpdateSearcher()
$historyCount = $Searcher.GetTotalHistoryCount()
$b = $Searcher.QueryHistory(0, $historyCount) | Select-Object Date,Title,@{name="Operation"; expression={switch($_.operation){1 {"Installation"}; 2 {"Uninstallation"}; 3 {"Other"}}}},@{name="Status"; expression={switch($_.resultcode){ 1 {"In Progress"}; 2 {"Succeeded"}; 3 {"Succeeded With Errors"}; 4 {"Failed"}; 5 {"Aborted"};}}}
$b
It actually would have almost worked except for the odd line breaks and the messed up items in the switch statements. I also added the output of the variable $b to the end to show it working.
HTH.
Wednesday, April 8, 2015 5:32 AM
Hi rama,
Could you please let us know whether you are getting any error when you are running the script on your 2003 anhd 2008 servers.
Naveen Basati
Wednesday, April 8, 2015 6:20 PM
am running this from a remote computer 2008 server
Wednesday, April 8, 2015 7:41 PM
am running this from a remote computer 2008 server
Post your errors:
\(ツ)_/
Thursday, April 9, 2015 4:07 AM
Hi Jrv,
Your code was perfect and it is working fine, complex-free.
Naveen Basati
Thursday, April 9, 2015 5:07 AM
Hi Rama,
I think you would have just copied and paste the code from the article and tried to run it out without sorting it out. Daniel Scott has sorted it for you, But I felt it bit complex. But its working well.
Naveen Basati