Who remembers systeminfo? I liked to use systeminfo | more on my Windows XP and Win 7 systems to get the boot datetime, but Microsoft appears to have stripped the property in Windows 8 and Windows Server 2012. At any rate, it’s not what I want.
What would you say is the most efficient way in Windows PowerShell v3 or later to get not the boot time but the elapsed uptime of the box in an eyeball-friendly format?
Ultimately, I’d like to add this function to my profile script so I see the info at-a-glance every time I start the console. I’d like to see output that is similar to the following:
Uptime: 8 days, 12 hours, 36 minutes
Thanks much! Glad to be a part of this community.
Respectfully,
Tim W.
PS: I did use the forum search for “uptime” before submitting this topic.
If you mean aggregate uptime, probably nothing easy. If you mean current uptime since last reboot, it’s query Win32_OperatingSystem using CIM, get the last boot time, and calculate (it’s simple subtraction).
Windows 8 will throw you all off, though. By default, when you “Shut down” a Windows 8 computer, you’re actually going into a sleep / hibernate state, and waking up from that doesn’t reset the WMI LastBootUpTime value (but a reboot does; go figure.) You can figure out the last “boot” time on Windows 8 by searching the event log, though. Shutdown and Fast startup in Windows 8 – Let IT know is where I found some more details on that.
Just returning the favor Tim, I recognized you right away. I took your 70-412 video course back in March of this year on CBT Nuggets when I was preparing for my MCSA 2012. It was most helpful…
Dave, thanks for pointing that out! I, for one, did not know about this default behavior in Win8