Get Windows install date

PowerShell Service Status Sometimes when working with a new customer or dealing with a specific issue I’ve found myself in the need to find out Windows installation date, while there are various places where Windows writes the information I usually find it quicker and easier to use PowerShell for the task.

Getting Windows install date is really easy using a command similar to the following:

#Get Windows installation date from WMI
$osInstallDate = get-wmiobject win32_operatingsystem

#Convert date to desired format
$osInstallDate.ConvertToDateTime($os.InstallDate) -f "MM/dd/yyyy"

The above code will produce an output similar to the following (from one of my Lab machines):

03/23/2014 21:14:43

While it is functional and giving exactly the information we need, Windows install date, not many more details are shown and does not scale well, if we need to perform the same operation for multiple servers something like the following code is more functional and appropriate:

$computers = get-content C:HeloCheckComputers.txt

foreach ($host in $computers) 
    {
       get-wmiobject win32_operatingsystem | 
        select @{Name="Installed";
        Expression={$_.ConvertToDateTime($_.InstallDate)}},
        Caption, Version
    }

The above code will read a list of computer names from the Computers.txt file and will then get the installation date for each of them producing and output similar to the following giving us Windows install date together with Windows version, as you can see I’m running Windows 2008R2 with build version 6.1.7601

Installed                                 Caption                                   Version
---------                                 -------                                   -------
23.03.2014 21:14:43                       Microsoft Windows Server 2008 R2 Enter... 6.1.7601
23.03.2014 21:14:43                       Microsoft Windows Server 2008 R2 Enter... 6.1.7601

I hope you’ll find the above useful and will tke a second to share the article and subscribe to RSS feeds to never lose and update!

And you? Are you using a script to find Windows install date? It would be great to read your script and hear your experience.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s