Learn about Windows PowerShell
Summary: Learn how to use Windows PowerShell to display last boot up time.
How can I use Windows PowerShell to find the last time a workstation booted up?
Use the WMI Class Win32_OperatingSystem and select the LastBootupTime property. Using the Get-CimInstance cmdlet returns a properly formatted DateTime object, for example:
Hi, is it possible to confirm which versions of PowerShell this will work with?
The CIM cmdlets came out with PowerShell 3. For PowerShell 2, use Get-WmiObject
And, if you're going to use Get-WmiObject, please consider that it will not, by default, return a properly formatted datetime object. This example should help in that case: [Management.ManagementDateTimeConverter]::ToDateTime((Get-WmiObject -Class Win32_OperatingSystem
| Select-Object -Property LastBootupTime).LastBootupTime)
just wrote a full blog post on the subject:
Hope you find it interesting!
I wrote this a while ago.
Get-CimInstance -ClassName Win32_OperatingSystem | select computername, lastbootuptime