PowerTip: Get the Last Boot Time with PowerShell

Doctor Scripto

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

 

 

0 comments

Discussion is closed.

Feedback usabilla icon