March 27th, 2013

PowerTip: Get the Last Boot Time with PowerShell

Doctor Scripto
Scripter

Summary: Learn how to get the last boot time for your computer.

Hey, Scripting Guy! Question How can I find the last boot time for my computer by using Windows PowerShell?

Hey, Scripting Guy! Answer In Windows PowerShell 3.0, use the Get-CimInstance cmdlet, and select the LastBootUptime property from the Win32_Operatingsystem WMI class:

PS C:\> Get-CimInstance -ClassName win32_operatingsystem | select csname, lastbootuptime

csname                                     lastbootuptime

——                                     ————–

EDLT                                       3/22/2013 11:27:01 AM

Hey, Scripting Guy! Answer In Windows PowerShell 2.0 and Windows PowerShell 1.0, use the Get-WmiObject cmdlet, and then translate the returned date to a readable format:

PS C:\> Get-WmiObject win32_operatingsystem | select csname, @{LABEL=’LastBootUpTime’

;EXPRESSION={$_.ConverttoDateTime($_.lastbootuptime)}}

csname                                     LastBootUpTime

——                                     ————–

EDLT                                       3/22/2013 11:27:01 AM

 

 

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.