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 🙂