July 11th, 2014

PowerTip: How Long Has My Computer Been Running?

Doctor Scripto
Scripter

Summary: Learn a one-liner Windows PowerShell command to see how long a computer has run.

Hey, Scripting Guy! Question How can I use Windows PowerShell to find out how long my computer has been running
          since last boot up without writing a script?

Hey, Scripting Guy! Answer Use the Win32_OperatingSystem WMI class and the LastBootupTime property,
          and then subtract the value of the current date/time that comes from Get-Date:

(Get-Date) – (Get-CimInstance Win32_operatingSystem).lastbootuptime

Author

The "Scripting Guys" is a historical title passed from scripter to scripter. The current revision has morphed into our good friend Doctor Scripto who has been with us since the very beginning.

0 comments

Discussion are closed.