PowerShell One-liner to Extract a Windows 10 Upgrade Error Code

Short post – here’s a PowerShell one-liner that will extract the upgrade code from the setupact.log generated by a Windows 10 upgrade. It includes both the result code and the extend code. You could include this in an in-place upgrade task sequence with ConfigMgr to stamp the code to the registry, or WMI, or create a task sequence variable etc.


(Get-Content -ReadCount 0 -Path "$env:SystemDrive\`$Windows.~BT\Sources\Panther\setupact.log" |
    Out-String -Stream |
    Select-String -SimpleMatch "MOUPG  SetupHost: Reporting error event").ToString().Split('>')[1].Replace('[','').Replace(']','').Trim()

Here’s an example containing the code for happiness, 0xC1900210, 0x5001B 🙂

errorcode

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.