Finding your Windows Install Date

08 Jun, 2023

Did you ever need to find when you installed your operating system? Check out the many ways to check your Windows Operating System. I was reading another blog post by Adam's Desk on How to Find the Linux Install Date when I remembered how we can do this on a Windows operating system as well.

What I find the most interesting is how much information the operating system stores about itself and the tools and ways you can get that information. I'll explore the registry, the Windows Management Instrumentation or WMI, and a few built in system tools.

Registry

Windows stores a lot of information in the Registry and there is an InstallDate key which stores the install date in seconds or UNIX time.

Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion

You can query this registry hive location and get the value of the InstallDate item. Since this will return a timestamp we need to convert that to a human readable timestamp. The second option below will show the Universal Time Zone or UTC of the date.

# Get timestamp from registry
$installdate = (get-itemproperty 'HKLM:\Software\Microsoft\Windows NT\CurrentVersion').InstallDate

# Convert timestamp to local time from the Unix Time Stamp
Get-Date -UnixTimeSeconds $installdate

# Convert the timestamp to UTC time
(Get-Date -Date "1970-01-01 00:00:00Z").toUniversalTime().addSeconds($installdate)

# All in one way to get the infomration
[timezone]::CurrentTimeZone.ToLocalTime(([datetime]'1/1/1970').AddSeconds($(get-itemproperty 'HKLM:\Software\Microsoft\Windows NT\CurrentVersion').InstallDate))

Using systeminfo

Windows has had the systeminfo command that has always been in the operating system that is gathers a bunch of information that is beneficial for many reasons. You can run the following either in Powershell or command promt and the pipe command we can then find and serach for the text we want from the output.

systeminfo | find "Install Date"

The Powershell equivalent is the Get-ComputerInfo command. This has more information in the output object.

Get-ComputerInfo | select OSInstallDate,WindowsInstallDateFromRegistry

Using WMI

The Windows Management Instrumentation is a way to interact with the operating system at the OS level down to the driver and hardware level as well. You can perform changes to the OS and also gather information as well. In Powershell 5.1 and higher the Get-CimInstance is proffered over the Get-WmiObject and wmic. We need to query the Win32_OperatingSystem class in the WMI system to get the information we need.

Get-CimInstance Win32_OperatingSystem | Select InstallDate

History of the upgrades

Since the registry contains current and past information about the operating system, we can even query the system to check the original install and it even knows the history of the upgrades to the Operating System and build release updates.

$OS=@(Get-ChildItem -Path HKLM:\System\Setup\Source* | ForEach-Object {Get-ItemProperty -Path Registry::$_}; Get-ItemProperty 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion')

$OS | Select-Object ProductName, ReleaseID, CurrentBuild, @{Name='InstallDate'; Expression={[timezone]::CurrentTimeZone.ToLocalTime(([datetime]'1/1/1970').AddSeconds($_.InstallDate))}} | Sort-Object "InstallDate"

Conclusion

As you can see there are many ways to gather system information from the operating system. With the many different ways to gather the information we can use the method that works best for us at the time. Some are a little quicker than others as well. The WMI calls have a history of being slow to return a value, while others might be simple in nature and more complex. Try building this into a system information script of your own!

What is your install date? Do you have a history of updates as well?


I'm publishing this as part of 100 Days To Offload. You can join in yourself by visiting 100DaysToOffload.com.

Tags: powershell, windows, 100DaysToOffload

Webmentions

If there are replies, they will show below.

2 Likes

1 Reply

Adam Adam
@cjerrington You beat me to it 😏. Hey thanks for the shout out!


Found an issue? Edit on Github

← Back home