PowerTip: Use PowerShell to Find System Uptime

Summary: Use Windows PowerShell to find your system uptime.

Hey, Scripting Guy! Question How can I use Windows PowerShell to easily find how long my computer has been running?

Hey, Scripting Guy! Answer Use the Get-Date cmdlet to return the current date and time, and then subtract the value
           of the LastBootUpTime property that comes from the Win32_OperatingSystem, for example:

(get-date) - (gcim Win32_OperatingSystem).LastBootUpTime

Note  GCIM is an alias for Get-CimInstance.

Comments (1)

  1. Panda says:

    This will be off by an hour if daylight saving time change occurred in that period.

Skip to main content