Undetectable Humanizer: Lifetime Subscription
Transform AI-Generated Text into Human-Like, High-Ranking Content & Bypass Even the Most Sophisticated AI Detectors
Get 95% Deal

Display the Windows upgrade history using PowerShell

Martin Brinkmann
Mar 23, 2018
Windows, Windows 10
|
14

It may sometimes be useful to look at the upgrade history of a PC running Windows. Maybe you would like to know about the first installed version of Windows on the PC, or need to look up the information for troubleshooting or analysis.

The Windows Registry holds the information under the key Computer\HKEY_LOCAL_MACHINE\SYSTEM\Setup and the information there may be all you require.

Just check the Source OS key and browse the data stored under each key to find out about previously installed versions and editions of Windows.

windows installed versions

Information that is revealed to you when you browse a Source OS key in the Registry includes the operating system's product name, registered owner and installation path, build number, and installation date among others.

You may use PowerShell commands to list core information. It is just another option to display the Windows upgrade history.

Using PowerShell

windows upgrade history

You need to open a PowerShell prompt to run the commands. Note that you don't need elevated privileges for that:

  • Tap on the Windows-key, type powershell and select the program from the list of results.

With PowerShell open, run the following commands using copy and paste.

Command 1: $AllBuilds = $(gci "HKLM:\System\Setup" | ? {$_.Name -match "\\Source\s"}) | % { $_ | Select @{n="UpdateTime";e={if ($_.Name -match "Updated\son\s(\d{1,2}\/\d{1,2}\/\d{4}\s\d{2}:\d{2}:\d{2})\)$") {[dateTime]::Parse($Matches[1],([Globalization.CultureInfo]::CreateSpecificCulture('en-US')))}}}, @{n="ReleaseID";e={$_.GetValue("ReleaseID")}},@{n="Branch";e={$_.GetValue("BuildBranch")}},@{n="Build";e={$_.GetValue("CurrentBuild")}},@{n="ProductName";e={$_.GetValue("ProductName")}},@{n="InstallTime";e={[datetime]::FromFileTime($_.GetValue("InstallTime"))}} };

Command 2:  $AllBuilds | Sort UpdateTime | ft UpdateTime, ReleaseID, Branch, Build, ProductName

PowerShell returns previous Windows versions in a table when you execute the second command. If you run Windows 10, you may get various Windows 10 feature updates builds returned to you.

If the machine was update from a previous version of Windows, you get its product name listed there as well.

The information may be useful. You can find out if the system was upgraded from a previous version of Windows, or which feature updates of Windows 10 were installed on it prior to the one that is installed currently on the device.

You could verify that the PC you bought was not upgrade from a previous version of Windows but clean-installed.

Now You: What happens when you run the script on your Windows machine? (via Deskmodder)

Related articles

Summary
Display the Windows upgrade history using PowerShell
Article Name
Display the Windows upgrade history using PowerShell
Description
It may sometimes be useful to look at the upgrade history of a PC running Windows. Maybe you would like to know about the first installed version of Windows on the PC, or need to look up the information for troubleshooting or analysis.
Author
Publisher
Ghacks Technology News
Logo
Advertisement

Tutorials & Tips


Previous Post: «
Next Post: «

Comments

  1. ilev said on March 25, 2018 at 10:49 am
    Reply

    My Windows 7 SP1 doesn’t have an entry for :
    HKEY_LOCAL_MACHINE\SYSTEM\Setup\Source OS.

  2. Just an ordinary win user said on March 24, 2018 at 8:45 am
    Reply

    Powershell is another BIG mistake of MÄ°crosoft , VBS is much more userfriendly and Efficient

    1. VBScript is “lighter” than PowerShell. It utilizes less memory and is generally “faster” than PowerShell at doing the same tasks

    2. To Manage Computers that Can’t Run PowerShell you must use vbs

    3. On Windows XP and Windows Server 2003 , PowerShell needs to be installed as part of the Windows Management Framework 2.0

    4.Microsoft has not allowed PowerShell to run inside of an MSI file, so admins are still forced to use VBScript

    Et. Unfortunatelly I must say this : Satya Nadella has no talent to be a Ceo

    1. mumu said on November 10, 2019 at 2:36 pm
      Reply
    2. BM said on April 1, 2018 at 7:57 pm
      Reply

      A great example of a non sequitur.

      No argument with the good points 1 to 4.

      But a CEO must focus on things well beyond tools that the most technically adept would prefer to use, unless, of course, that is precisely the market they are primarily focused on. MS is not.

      Nadella is shifting focus away from the operating system – seems smart given MS’ failures to foresee and leverage the overall move towards mobile.

      MS no longer dominates – ceding major ground to mostly Google / Alphabet. Windows may well become irrelevant in 10 to 15 years.

  3. no_escape said on March 23, 2018 at 9:13 pm
    Reply

    code above is very ugly only because of the pain in the ass parsing of the install, which is in hexadecimal format

    powershell is very user friendly, you probably don’t see it because you don’t understand it or haven’t worked with any object oriented language

  4. Mike said on March 23, 2018 at 5:02 pm
    Reply

    OR

    $Session = New-Object -ComObject “Microsoft.Update.Session”
    $Searcher = $Session.CreateUpdateSearcher()

    $historyCount = $Searcher.GetTotalHistoryCount()

    $s = $Searcher.QueryHistory(0, $historyCount)

    [psobject[]]$out = @()

    foreach ($obj in $s)
    {

    $title = $obj.Title
    $t1 = $title | select-string “\(.+\)” | Select-Object -ExpandProperty Matches | Select-Object -ExpandProperty value

    $ErrorActionPreference = “SilentlyContinue”
    $t2 = $t1.Replace(“(“,””)
    $id = $t2.Replace(“)”,””)
    $ErrorActionPreference = “Continue”

    $psObj = New-Object PSObject
    $psObj | Add-Member -Name ID -MemberType Noteproperty -Value $id
    $psObj | Add-Member -Name Title -MemberType NoteProperty -Value $obj.Title
    $psObj | Add-Member -Name Date -MemberType NoteProperty -Value $obj.Date
    $out += $psObj
    }

    $out | Format-Table

  5. basicuser said on March 23, 2018 at 1:36 pm
    Reply

    What happens when you run the script on your Windows machine?

    FWIW, This is W7 Pro on an ASUS Pro box bought in February 2015.

    Using the PowerShell commands, I get the following return each time:
    PS C:\Windows\System32\WindowsPowerShell\v1.0>

    In the registry under SetupCI there is only one folder named PendingRequest with the following information:

    NAME: Default TYPE: REG­_SZ DATE:
    (value not set)

    I have no idea what this means.

  6. Hawk said on March 23, 2018 at 1:23 pm
    Reply

    Nothing appear on my Win 7 Ultimate x32

  7. Yuliya said on March 23, 2018 at 1:22 pm
    Reply

    Precisely, nothing, on a fresh install of 7: imgur.com/l3IpWZr
    Would have been nice a message there “yay, your OS is clean”. Since it returned no errors I assume the command worked.

    1. Weilan said on March 23, 2018 at 2:10 pm
      Reply

      Me too. The first thing I do when I install my Windows 7 is to disable Windows Update, remove all updates, including Internet Explorer and returning it to version 8.

      1. Anonymous said on March 24, 2018 at 7:31 pm
        Reply

        That’s just horrible. Security updates are there for a reason.

      2. Anonymous said on March 23, 2018 at 4:46 pm
        Reply

        And this is why we have forced updated in Windows 10.

  8. jupe said on March 23, 2018 at 10:53 am
    Reply

    Powershell, although powerful, not user friendly

    1. Mr. Stank said on March 23, 2018 at 12:06 pm
      Reply

      Exactly this. I do not understand why this year so many sites advice the use of ths tool. It is not even for the average user.

Leave a Reply

Check the box to consent to your data being stored in line with the guidelines set out in our privacy policy

We love comments and welcome thoughtful and civilized discussion. Rudeness and personal attacks will not be tolerated. Please stay on-topic.
Please note that your comment may not appear immediately after you post it.