I want to get all of this information (including non-windows updates) in any text format... Please share if you have any way to fetch these infos. For more details please see attached image...
-
1http://social.technet.microsoft.com/wiki/contents/articles/4197.how-to-list-all-of-the-windows-and-software-updates-applied-to-a-computer.aspx – David Brabant Apr 21 '16 at 07:03
4 Answers
Try this way:
$Session = New-Object -ComObject Microsoft.Update.Session
$Searcher = $Session.CreateUpdateSearcher()
$HistoryCount = $Searcher.GetTotalHistoryCount()
$Updates = $Searcher.QueryHistory(0,$HistoryCount)
$Updates | Select Title,@{l='Name';e={$($_.Categories).Name}},Date

- 3,118
- 1
- 15
- 20
-
1Nice, this works good. I am trying to filter out it for only important updates but couldn't find anything. Do you have any suggestion on that ? Thank you! – Kumar Sambhav Pandey Aug 14 '18 at 06:52
-
@Sambhav, you sure can! Change $Updates = $Searcher.QueryHistory(0,$HistoryCount) to $Updates = $Searcher.Search("IsInstalled=1").Updates | where { $_.MsrcSeverity -eq "Important" } . But be aware of that Search method works REALLY slow. – Kirill Pashkov Aug 28 '18 at 10:05
-
Edit:
To get all the updates (installed via Windows Update only, even for 3rd party) and then export the result to a text file, you can use below script:
$session = [activator]::CreateInstance([type]::GetTypeFromProgID(“Microsoft.Update.Session”,$ComputerName))
$us = $session.CreateUpdateSearcher()
$qtd = $us.GetTotalHistoryCount()
$hot = $us.QueryHistory(0, $qtd)
# Output object
$OutPut = @()
#Iterating and finding updates
foreach ($Upd in $hot) {
# 1 means in progress and 2 means succeeded
if ($Upd.operation -eq 1 -and $Upd.resultcode -eq 2) {
$OutPut += New-Object -Type PSObject -Prop @{
‘ComputerName’=$computername
‘UpdateDate’=$Upd.date
‘KB’=[regex]::match($Upd.Title,’KB(\d+)’)
‘UpdateTitle’=$Upd.title
‘UpdateDescription’=$Upd.Description
‘SupportUrl’=$Upd.SupportUrl
‘UpdateId’=$Upd.UpdateIdentity.UpdateId
‘RevisionNumber’=$Upd.UpdateIdentity.RevisionNumber
}
}
}
#Writing updates to a text file
$OutPut | Out-File -FilePath "C:\output.txt" -Append
Older Response:
Instead of creating your own script you can use this wonderful script from Technet: PowerShell script to list all installed Microsoft Windows Updates
As you want the output in text format, I have updated the script from that article to generate output for all the installed updates in a text file. Everything is configurable. Check the complete script below. The last line is where I am invoking the reusable method and generating the output into a text file. You can change the path to this text file as per your environment.
Function Get-MSHotfix
{
$outputs = Invoke-Expression "wmic qfe list"
$outputs = $outputs[1..($outputs.length)]
foreach ($output in $Outputs) {
if ($output) {
$output = $output -replace 'y U','y-U'
$output = $output -replace 'NT A','NT-A'
$output = $output -replace '\s+',' '
$parts = $output -split ' '
if ($parts[5] -like "*/*/*") {
$Dateis = [datetime]::ParseExact($parts[5], '%M/%d/yyyy',[Globalization.cultureinfo]::GetCultureInfo("en-US").DateTimeFormat)
} elseif (($parts[5] -eq $null) -or ($parts[5] -eq ''))
{
$Dateis = [datetime]1700
}
else {
$Dateis = get-date([DateTime][Convert]::ToInt64("$parts[5]", 16))-Format '%M/%d/yyyy'
}
New-Object -Type PSObject -Property @{
KBArticle = [string]$parts[0]
Computername = [string]$parts[1]
Description = [string]$parts[2]
FixComments = [string]$parts[6]
HotFixID = [string]$parts[3]
InstalledOn = Get-Date($Dateis)-format "dddd d MMMM yyyy"
InstalledBy = [string]$parts[4]
InstallDate = [string]$parts[7]
Name = [string]$parts[8]
ServicePackInEffect = [string]$parts[9]
Status = [string]$parts[10]
}
}
}
}
Get-MSHotfix|Select-Object -Property Computername, KBArticle,InstalledOn, HotFixID, InstalledBy|Format-Table | Out-File -FilePath "D:\output.txt"

- 1,930
- 1
- 17
- 31
-
Thanks Aman Sharma, but i want to confirm that, can we get listed non-windows products too? Using this Script! – Jay Panchal Apr 21 '16 at 12:36
-
1
-
1As @majkinetor mentioned, this and any other method mentioned in other answers will only fetch Windows Updates only. – Aman Sharma Apr 21 '16 at 18:08
-
1@JayPanchal I have provided an update to the answer. Please try this new script. I have provided as per your requirement. – Aman Sharma Apr 21 '16 at 18:35
Run the following command using powershell. You can easily redirect Select-Object
to an out-file
Get-WmiObject -Class Win32_QuickFixEngineering
Please refer Win32_QuickFixEngineering for more information.

- 1,396
- 12
- 27
The easiest way
Install-Module PSWindowsUpdate -force
Get-WuHistory
Install-Module
works on Posh5. For older use chocolatey: cinst PSWindowsUpdate
.

- 8,730
- 9
- 54
- 72
-
Is it listing non-windows updates too?, Though i tried it, but i am not able to get non-windows updates...details... – Jay Panchal Apr 21 '16 at 12:55
-
1No. I didnt see that part sorry. U need different code then but that is very easy to find everywhere. – majkinetor Apr 21 '16 at 16:47
-
Yup! No worries! And by the way thanks for your effort! i'll try to dig it in deep! – Jay Panchal Apr 25 '16 at 09:25
-
1This is the hard part anyway and with above code it becomes very easy. – majkinetor Apr 25 '16 at 09:57