ScioSoft's Community Blogs Optimized IT musings for the technically inclined

PowerShell: Get OS Installation Date

by James Fielding 18. October 2011 19:43
Here is a quick, and oh-so-easy, one-liner to see when you installed a machine’s Operating System:
([WMI]'').ConvertToDateTime((Get-WmiObject Win32_OperatingSystem).InstallDate)
The main part of the command gets the install date:
(Get-WmiObject Win32_OperatingSystem).InstallDate
The problem is, if you just run this command, the result is not so human-friendly:
20090328134854.000000-240
To fix this up, we can apply the ConvertToDate method, which is actually a Common helper method (that has nothing to do with the Win32_Service WMI class). To do this I used /\/\o\/\/’s method of creating an "Empty" WMI class for this ([WMI]''):
([WMI]'').ConvertToDateTime()
Once we do this, we get a nice, human-friendly result:
March-28-09 1:48:54 PM
Happy OS Dating (…judging by the date on my system, it looks like it is time for a reimage),
James Fielding

Sciosoft Systems is a Canadian web design & development company based in Muskoka, which is in central Ontario. We provide ASP.NET website & Windows Server application development services to small and medium-sized business, as well as local government and not-for-profit groups. If you have a website project you’d like to discuss, please visit us at www.sciosoft.com.

Share |

Tags: , ,

IT Systems | PowerShell

RecentComments

Comment RSS

The opinions expressed herein are the personal opinions of the contributors and do not necessarily represent the views of Sciosoft Systems Inc.