PowerShell command outputting 'System.__ComObject' on Windows 11 23H2

VM 61 Reputation points
2024-07-02T12:00:45.7933333+00:00

I am working on a Windows 11 23H2 system and attempting to retrieve installed update details using the PowerShell command below, but it's giving me an output of System.__ComObject:

$UpdateSession = New-Object -ComObject 'Microsoft.Update.Session'

$UpdateSearcher = $UpdateSession.CreateUpdateSearcher()

$Updates = $UpdateSearcher.Search('IsInstalled=1')

$result.Updates | Format-Table Title

Attached is a screenshot of the code and output for reference:

User's image

PowerShell
PowerShell
A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
2,582 questions
{count} votes

5 answers

Sort by: Most helpful
  1. Darrin DiNapoli 20 Reputation points
    2024-07-10T22:13:27.3033333+00:00

    Hello! I've been tracking and troubleshooting this issue since June. Today I found a simple method to effectively revert WUAPI to its "non-Preview" build, using a config file (C:\ProgramData\Microsoft\Windows\OneSettings\UusSettings.json). Here's an unmodified sample:

    {"queryUrl":"/settings/v3.0/WSD/UUS","settings":{"EXCLUSIONS":["1023.201.1012.0","121.511.1.0","1023.413.2122.0","1022.1108.2012.0"]}}

    What I found is that the versions in this file are old Preview builds, and adding the latest Preview version (now 1306.2405.21022.0) will cause Windows to ignore this version and fall back to the non-Preview build (now 1219.2405.8012.0). Edit the file (Admin elevation required), reboot and you'll see the change (run (New-Object -ComObject Microsoft.Update.AgentInfo).GetInfo('ProductVersionString') before and after).

    The following code will get the currently active WUAPI version and add it to UusSettings.json after creating a backup of the file. So far in my testing this fully restores API functionality!

    NOTE: The two Out-File commands are necessary to reconstruct UusSettings.json in the correct format (UTF8 with no BOM) so Windows recognizes the file and honors the exclusions.

    $wuVer = (New-Object -ComObject Microsoft.Update.AgentInfo).GetInfo('ProductVersionString')
    $uusJson = "C:\ProgramData\Microsoft\Windows\OneSettings\UusSettings.json"
    $uusJsonBAK = "C:\ProgramData\Microsoft\Windows\OneSettings\UusSettings.json.BAK"
    $uusObj = Get-Content $uusJson | ConvertFrom-Json
    if ($uusObj.settings.EXCLUSIONS -notcontains $wuVer) {
        Copy-Item $uusJson $uusJsonBAK -Force
        $uusObj.settings.EXCLUSIONS += "$wuVer"
        " " | Out-File $uusJson -Encoding ascii -NoNewline -Force
        $uusObj | ConvertTo-Json -Compress | Out-File $uusJson -Encoding UTF8 -Append -Force
    }
    
    4 people found this answer helpful.

  2. Pablo Navarro 10 Reputation points
    2024-07-14T23:41:28.2933333+00:00

    Microsoft acknowledged this issue and has released a way to roll it back through Known Issue Rollback: https://learn.microsoft.com/en-us/windows/release-health/status-windows-11-23H2#3351msgdesc

    No need to add many random versions to UusSettings.json, it will directly go back to 1219.2405.8012.0 if this rollback is applied.

    PS: You can quickly apply this rollback with this command will also work :)
    reg add HKLM\SYSTEM\CurrentControlSet\Policies\Microsoft\FeatureManagement\Overrides /v 1931709068 /t REG_DWORD /d 0

    Remember you need to reboot to make it work.

    1 person found this answer helpful.

  3. MotoX80 34,346 Reputation points
    2024-07-02T14:13:23.6733333+00:00

    You have a slight problem because there is no $result variable. That doesn't matter because even if you use the $Updates variable, you still have the same problem. I found that your code works for me on Win10, but fails on my Win11 22H2 laptop.

    To query update history you can use this code.

    $UpdateSession = New-Object -ComObject 'Microsoft.Update.Session'
    $UpdateSearcher = $UpdateSession.CreateUpdateSearcher()
    $UpdateSearcher.QueryHistory(0,100) | format-table -Property ResultCode, Date, Title
    
    
    

    You can also use the PSWindowsUpdate module. Here is what I use.

    # Install-Module -Name PSWindowsUpdate    # run this to install it 
    Get-WUHistory -Last 100 | where-object -Property Title -notlike "Security Intelligence Update*" | format-list -Property Result, Date, Title
    

    Note that Get-WUHistory hangs for me if I don't limit the search with a -Last parameter.


  4. Richard Rodriguez 0 Reputation points
    2024-07-09T19:31:07.98+00:00

    Looks like KB5040442 today has increased the audience for this issue. Win11 devices I had that were unaffected last week are now in this state without the ability to force the older version of WUA via the Overrides registry key mentioned in the other comment thread.

    $wuAgentVer = (New-Object -ComObject Microsoft.Update.AgentInfo).GetInfo('ProductVersionString')

    returns 1306.2405.21022.0


  5. Deleted

    This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.


    Comments have been turned off. Learn more

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.