How to get all details from Installed Updates Window

风流意气都作罢 提交于 2019-12-14 03:54:07

问题


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


回答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"



回答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



回答3:


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.




回答4:


The easiest way

Install-Module PSWindowsUpdate -force
Get-WuHistory

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



来源:https://stackoverflow.com/questions/36761787/how-to-get-all-details-from-installed-updates-window

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!