Q: How can I use PowerShell to get the last boot time for a server using PowerShell?
A: If you have PowerShell 3.0 you can use WMI and the Get-CimInstance cmdlet to return the date and time of the last time the server was booted up. To retrieve the last bootup date and time you can select the LastBootUptime property from the Win32_Operatingsystem WMI class like you can see in the following listing.
PS C:\Users\Administrator> Get-CimInstance -ClassName win32_operatingsystem | select csname, lastbootuptime
The csname property returns the computer name and the lastbootuptime property returns the date and time of the last system boot. You can see an example of the output of the Get-CimInstance below.
WS2016-N0 12/14/2015 7:40:06 AM