October 4th, 2015

PowerTip: Use PowerShell to Find System Uptime

Doctor Scripto
Scripter

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.

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.