How to do it...

To build a script that shows us the last system boot time, perform the following steps:

  1. Launch PowerShell ISE as an Administrator.
  2. Open up a new script file and input the following line:
     Get-WmiObject -Class Win32_OperatingSystem -ComputerName  
      localhost | Select-Object -Property LastBootUpTime
  1. We have some data! It's kind of messy data, though. Maybe we can clean that up and make it a little more readable. With a couple of changes to our Select-Object code, we can change the header for this data to something more friendly, as well as changing the output of the date and time so it's way easier on the eyes:
 Get-WmiObject ...

Get Windows Server 2016 Administration Cookbook now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.