Get the Computer Uptime (Last Boot Time) on Windows Using PowerShell

Posted by

Knowing how long your Windows computer has been running can help you troubleshoot performance problems, check whether a recent restart was successful, and determine when your system last started. This information is especially useful when your PC feels sluggish, Windows updates require a restart, or you want to verify whether a scheduled reboot actually happened.

Fortunately, you don’t need to install third-party software to check your computer’s uptime. PowerShell, a command-line shell included with Windows, lets you retrieve the system’s last boot time and calculate how long the computer has been running.

You can use a single command to display the last boot time, calculate the total uptime in days and hours, or retrieve additional system information for troubleshooting. If you’re new to PowerShell, don’t worry. 

The following methods walk you through each step, explain what the commands do, and show you how to interpret the results on Windows 11 and Windows 10.

Get the Computer Uptime (Last Boot Time) on Windows Using PowerShell

Get the Computer Uptime (Last Boot Time) on Windows Using PowerShell
Get the Computer Uptime (Last Boot Time) on Windows Using PowerShell
  1. Press Windows + X and select Terminal or Windows PowerShell from the menu.
  2. Enter Get-CimInstance Win32_OperatingSystem | Select-Object LastBootUpTime and press Enter to view the last boot time.
  3. Run (Get-Date) – (Get-CimInstance Win32_OperatingSystem).LastBootUpTime to calculate the computer’s uptime.
  4. Check the displayed days, hours, minutes, and seconds to determine how long Windows has been running.
  5. Use Get-Date and the last boot time together if you want to compare the current time with the most recent Windows startup.

These commands generally work without administrator privileges on a local Windows computer.

Step 1: Open PowerShell on Your Windows Computer

First, open PowerShell so you can enter the command that retrieves your computer’s startup information. 

On Windows 11, the easiest option is to open Windows Terminal, which commonly launches with PowerShell as its default profile. Windows 10 users can also open Windows PowerShell directly.

Press Windows + X on your keyboard to open the Quick Link menu. Select Terminal or Windows PowerShell, depending on the options available on your computer. If you see Windows Terminal, make sure its active tab is running PowerShell rather than Command Prompt.

You can also open the Start menu, type PowerShell, and select the appropriate application from the search results.

The usual navigation path is Start > Search > PowerShell > Open.

For the commands in this guide, you generally don’t need to select Run as administrator. Standard permissions are sufficient for querying the local operating system’s last boot time. However, elevated permissions may be necessary for certain administrative tasks or remote system queries.

Step 2: Find the Last Boot Time Using PowerShell

Once PowerShell is open, you can retrieve the exact date and time Windows most recently started by querying the Win32_OperatingSystem class.

Enter the following command and press Enter:

Get-CimInstance Win32_OperatingSystem | Select-Object LastBootUpTime

PowerShell displays a result containing the LastBootUpTime property. This value represents the date and time of the operating system’s most recent boot, according to Windows management information.

For example, your output might look like this:

LastBootUpTime

————–

10/13/2026 8:15:30 AM

The displayed date and time are only an example. Your actual result will depend on when your computer last started and your system’s regional date and time settings.

The command has two main parts. Get-CimInstance Win32_OperatingSystem retrieves information about the current Windows operating system. The pipe symbol (|) passes that information to Select-Object LastBootUpTime, which displays only the property you need.

This approach is useful when you want to check the last boot time without displaying unrelated system details.

Step 3: Calculate How Long Your Computer Has Been Running

The last boot time tells you when Windows started, but it doesn’t directly show the total uptime. To calculate that duration, subtract the last boot time from the current date and time.

Run this command in PowerShell:

(Get-Date) – (Get-CimInstance Win32_OperatingSystem).LastBootUpTime

Press Enter to display the elapsed time since the operating system’s recorded startup.

For example, the result might look similar to this:

Days              : 2

Hours             : 5

Minutes           : 30

Seconds           : 12

Milliseconds      : 450

Ticks             : 1926124500000

TotalDays         : 2.229

TotalHours        : 53.496

TotalMinutes      : 3209.77

TotalSeconds      : 192586.2

These numbers are illustrative. Your computer will display values based on its actual uptime.

The result is a TimeSpan object, which represents the difference between two points in time. Its Days, Hours, Minutes, and Seconds properties make it easy to understand how long your system has been running.

For example, Days: 2 and Hours: 5 means the computer has been running for two full days and five additional hours, with the minutes and seconds providing more detail.

This method is particularly helpful when troubleshooting a computer that hasn’t restarted for several days.

Step 4: Display the Uptime in a Simple, Readable Format

If you prefer a clean result instead of the full TimeSpan output, you can format the uptime to show only days, hours, minutes, and seconds.

Enter this command:

$uptime = (Get-Date) – (Get-CimInstance Win32_OperatingSystem).LastBootUpTime

“Computer uptime: (uptime.Days) days, (uptime.Hours) hours, (uptime.Minutes) minutes, and (uptime.Seconds) seconds”

PowerShell calculates the uptime, stores the result in a variable named $uptime, and then displays a readable message.

For example, the output could be:

Computer uptime: 2 days, 5 hours, 30 minutes, and 12 seconds

The $uptime variable temporarily stores the calculated duration so you can reuse it in other commands during the same PowerShell session.

Keep in mind that the Days property reports complete days, while Hours reports the remaining hours after complete days have been counted. This is why the formatted result doesn’t show the total number of hours across all days.

If you want total hours instead, use $uptime.TotalHours. For example, the command below displays the total uptime in hours, including fractional hours:

$uptime = (Get-Date) – (Get-CimInstance Win32_OperatingSystem).LastBootUpTime

“Total uptime: ([math]::Round(uptime.TotalHours, 2)) hours”

This format is convenient when you need a quick reading for a support ticket or maintenance record.

Step 5: Display Only the Last Boot Time in a Custom Format

Sometimes, you may need the startup date and time in a specific format for documentation or troubleshooting notes. PowerShell allows you to format the LastBootUpTime property using the ToString() method.

Run the following command:

(Get-CimInstance Win32_OperatingSystem).LastBootUpTime.ToString(“yyyy-MM-dd HH:mm:ss”)

The output follows the year-month-day and 24-hour time format. For example:

2026-10-13 08:15:30

This format is useful because it reduces ambiguity when recording dates. For instance, the month and day are clearly separated, and the 24-hour clock distinguishes morning from evening.

The command uses yyyy for the four-digit year, MM for the month, dd for the day, HH for the hour in 24-hour format, mm for minutes, and ss for seconds.

You can change the format string to suit your needs. For example, “MM/dd/yyyy hh:mm tt” produces a date with a 12-hour clock and an AM or PM indicator.

Step 6: Retrieve the Last Boot Time and Uptime Together

If you want to see both the last boot time and the elapsed uptime in one result, you can combine the information into a single PowerShell command.

Enter:

$os = Get-CimInstance Win32_OperatingSystem

$uptime = (Get-Date) – $os.LastBootUpTime

[PSCustomObject]@{

    LastBootTime = $os.LastBootUpTime

    Uptime       = $uptime.ToString()

}

This command retrieves the operating system information once, calculates the elapsed duration, and displays both values in a structured object.

The PSCustomObject creates a custom PowerShell object with two properties: LastBootTime and Uptime. PowerShell displays these properties in a table, making the information easier to read.

This approach is helpful when you’re checking system health or gathering basic troubleshooting details. You can also expand the object with additional properties, such as the computer name, if you need to document several systems.

Troubleshoot Incorrect or Unexpected Uptime Results

If the displayed uptime seems incorrect, start by checking the last boot time and comparing it with your recent computer activity.

One important detail is Fast Startup in Windows. When Fast Startup is enabled, shutting down the computer may save a kernel session rather than performing a complete shutdown. As a result, the next startup may not reset the recorded operating system uptime in the way you expect.

This behavior can make uptime appear older than the time since you last pressed the Shut down option.

To test whether a full restart changes the result, save your work and select Start > Power > Restart. After Windows starts again, reopen PowerShell and run the uptime command. A normal restart generally starts a new operating system session and resets the recorded boot time.

Also, make sure your system clock is correct. An inaccurate clock or changes to system time can complicate comparisons between the displayed startup time and your recollection of when the computer was restarted.

If the CIM command returns an error, check that you typed Win32_OperatingSystem correctly and that the PowerShell session is running normally. For local uptime checks, administrator access is usually unnecessary.

FAQs

How do I check the last boot time in Windows PowerShell?

Run Get-CimInstance Win32_OperatingSystem | Select-Object LastBootUpTime. PowerShell displays the date and time recorded for the operating system’s most recent boot.

How do I check how many hours my PC has been running?

Run (Get-Date) – (Get-CimInstance Win32_OperatingSystem).LastBootUpTime to calculate the uptime. To display the total hours directly, store the result in $uptime and use $uptime.TotalHours.

Do I need administrator privileges to check uptime?

No. You can generally retrieve the local computer’s last boot time and calculate its uptime from a standard PowerShell session. Some remote queries and administrative operations may require additional permissions.

Does computer uptime reset when I shut down Windows?

Not necessarily. With Fast Startup enabled, a normal shutdown may preserve the Windows kernel session. A full restart generally resets the operating system’s recorded boot time.

Can I check uptime on Windows 10 and Windows 11?

Yes. The Get-CimInstance Win32_OperatingSystem command works on both Windows 10 and Windows 11. The exact appearance of the PowerShell interface may differ depending on your Windows version and Terminal settings.

What is the difference between last boot time and uptime?

Last boot time is the recorded date and time when Windows last started its operating system session. Uptime is the elapsed duration between that timestamp and the current time.

Final Words

Checking your computer’s uptime with PowerShell is a straightforward way to understand when Windows last started and how long the system has been running. The Get-CimInstance Win32_OperatingSystem command provides the last boot time, while subtracting that value from Get-Date calculates the elapsed uptime.

For a quick check, use the basic commands in Steps 2 and 3. If you need a cleaner result for troubleshooting or maintenance records, use the formatted output in Steps 4 and 6.

Remember that Windows Fast Startup can affect how uptime appears after a shutdown. If the displayed value doesn’t match your expectations, perform a restart and check again. 

With these PowerShell techniques, you can quickly verify system uptime without installing additional software.

Leave a Reply

Your email address will not be published. Required fields are marked *