Determine when Windows was installed

When it comes to getting detailed information concerning a Windows server, good-old Windows Management Instrumentation (WMI) is still your friend.

For example, say you’re wondering when Windows was installed on your system. To find out, you could try using the Get-WmiObject cmdlet to retrieve information from the win32_operatingsystem WMI class on the system like this:

PS C:\> Get-WmiObject win32_operatingsystem

SystemDirectory : C:\Windows\system32
Organization  :
BuildNumber   : 8400
RegisteredUser : Windows User
SerialNumber  : 00133-30010-00805-AA162
Version     : 6.2.8400

Unfortunately I don’t see what I’m looking for here, so let’s pipe the output to the Format-List cmdlet (using its alias “fl”) to show everything in the class like this:

PS C:\> Get-WmiObject win32_operatingsystem | fl *

PSComputerName              : SEA-HOST-1
Status                  : OK
Name                   : Microsoft Windows Server 2012 Release Candidate
                      Datacenter|C:\Windows|\Device\Harddisk0\Partition2
FreePhysicalMemory            : 23289328
FreeSpaceInPagingFiles          : 3407872



InstallDate                : 20120620092210.000000-420


Ah, there it is, the property I’m looking for is InstallDate, so let’s pipe the output into the Select-Object cmdlet (using its alias “select”) like this:

PS C:\> Get-WmiObject win32_operatingsystem | select InstallDate

InstallDate
———–
20120620092210.000000-420

Now I’ve got just what I wanted, but unfortunately the date/time shown here isn’t human-friendly. Fortunately, I can use the ConvertToDateTime() method to make it readable as follows:

PS C:\> Get-WmiObject win32_operatingsystem | select @{Name=”Install Date”; Expression={$_.ConvertToDateTime($_.InstallDate)}}

Install Date
————
6/20/2012 9:22:10 AM

The above example makes use of a PowerShell feature called “calculated properties”. For more info on this feature, see here:
http://www.wservernews.com/go/1342690932177

By the way, what if you want to retrieve this information from a remote computer? Just include the -ComputerName parameter with the Get-WmiObject cmdlet, and if your current logon credentials aren’t sufficient you can include the -Credential parameter to specify credentials for the remote computer. For example:

PS C:\> Get-WmiObject -Computer SEA-HOST-1 -Credential SEA-HOST-1\Administrator win32_operatingsystem | select @{Name=”Install Date”; Expression={$_.ConvertToDateTime($_.InstallDate)}}

The above tip was previously published in an issue of WServerNews, a weekly newsletter from TechGenix that focuses on the administration, management and security of the Windows Server platform in particular and cloud solutions in general. Subscribe to WServerNews today by going to http://www.wservernews.com/subscribe.htm and join almost 100,000 other IT professionals around the world who read our newsletter!

Mitch Tulloch is an eleven-time recipient of the Microsoft Most Valuable Professional (MVP) award and a widely recognized expert on Windows Server and cloud computing technologies.  Mitch is also Senior Editor of WServerNews. For more information about him see http://www.mtit.com.

About The Author

Leave a Comment

Your email address will not be published. Required fields are marked *

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Scroll to Top