2

Installed Updates Window - On windows 10 Enterprise

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...

David Brabant
  • 41,623
  • 16
  • 83
  • 111
Jay Panchal
  • 75
  • 1
  • 2
  • 11
  • 1
    http://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 Answers4

2

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
Kirill Pashkov
  • 3,118
  • 1
  • 15
  • 20
  • 1
    Nice, 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
  • This is brilliant! – metablaster Oct 11 '20 at 08:57
1

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"
Aman Sharma
  • 1,930
  • 1
  • 17
  • 31
1

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.

Amit Shakya
  • 1,396
  • 12
  • 27
0

The easiest way

Install-Module PSWindowsUpdate -force
Get-WuHistory

Install-Module works on Posh5. For older use chocolatey: cinst PSWindowsUpdate.

majkinetor
  • 8,730
  • 9
  • 54
  • 72