PowerTip: Use PowerShell to Display Last Boot Time


Summary: Learn how to use Windows PowerShell to display last boot up time.

Hey, Scripting Guy! Question How can I use Windows PowerShell to find the last time a workstation booted up?

Hey, Scripting Guy! Answer Use the WMI Class Win32_OperatingSystem and select the LastBootupTime property.
          Using the Get-CimInstance cmdlet returns a properly formatted DateTime object, for example:

(Get-CimInstance Win32_operatingSystem).lastbootuptime

Comments (7)

  1. tommymaynard says:

    And, if you’re going to use Get-WmiObject, please consider that it will not, by default, return a properly formatted datetime object. This example should help in that case: [Management.ManagementDateTimeConverter]::ToDateTime((Get-WmiObject -Class Win32_OperatingSystem
    | Select-Object -Property LastBootupTime).LastBootupTime)

  2. James Harris says:

    Hi, is it possible to confirm which versions of PowerShell this will work with?

  3. Ed Wilson says:

    The CIM cmdlets came out with PowerShell 3. For PowerShell 2, use Get-WmiObject

  4. carlo says:

    Hi Ed,
    just wrote a full blog post on the subject:
    http://www.happysysadm.com/2014/07/windows-boot-time-explored-in-powershell.html
    Hope you find it interesting!
    Carlo

  5. falkor says:

    Get-CimInstance -ClassName Win32_OperatingSystem | select computername, lastbootuptime

Skip to main content