# encoding: ascii
# api: powershell
# title: Get-SystemInstallDate
# description: From greg’s repository on github.
# version: 0.1
# type: function
# author: greg zakharov
# license: CC0
# function: Get-SystemInstallDate
# x-poshcode-id: 4863
# x-archived: 2017-05-22T04:19:17
# x-published: 2014-01-31T06:06:00
#
#
#requires -version 2.0
function Get-SystemInstallDate {
  <#
    .NOTES
        Author: greg zakharov
  #>
  
  try {
    ([wmi]'').ConvertToDateTime((gwmi Win32_OperatingSystem).InstallDate)
  }
  catch [Management.Automation.RuntimeException] {
    if ($_.Exception) {
      [TimeZone]::CurrentTimeZone.ToLocalTime([DateTime]'1.1.1970').AddSeconds(
        (gp 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion').InstallDate
      )
    }
  }
}
