Determine Boot Time and Uptime

WMI can tell you when a system was booted, and this information can be re-calculated to find out the uptime:

$bootTime = Get-CimInstance -ClassName Win32_OperatingSystem | Select-Object -ExpandProperty LastBootupTime
$upTime = New-TimeSpan -Start $bootTime

$min = [int]$upTime.TotalMinutes
"Your system is up for $min minutes now."

Note that Get-CimInstance uses WinRM remoting by default when you use it to access remote systems via -ComputerName. Older systems may not yet be enabled for WinRM remoting, and still use DCOM.

Twitter This Tip! ReTweet this Tip!