PoshCode Archive  Artifact [09efd6095f]

Artifact 09efd6095f1dc98af46e7bcdb3d2d948f00bd5799e6c822375e46d7d2511b539:

  • File Get-SystemInstallDate.ps1 — part of check-in [38412d73b8] at 2018-06-10 13:47:03 on branch trunk — From greg’s repository on github. (user: greg zakharov size: 799)

# 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
      )
    }
  }
}