Windows Uptime

Last Boot Time

There are multiple ways to report Windows last boot time...

Powershell

Get-CimInstance Win32_OperatingSystem | Select-Object LastBootUpTime


Get-WinEvent -ProviderName EventLog | Where-Object {$_.Id -eq 6005 -or $_.Id -eq 6006} | Select-Object -First 1 TimeCreated


Get-WinEvent -ComputerName localhost -FilterHashtable @{logname = 'System'; id = 1074} -MaxEvents 1 | format-list


TimeCreated  : 07/05/2023 04:24:37ProviderName : User32Id           : 1074Message      : The process C:\Windows\servicing\TrustedInstaller.exe (MYHOSTNAME) has initiated the restart of computer MYHOSTNAME on behalf of user NT AUTHORITY\SYSTEM for the following reason: Operating System: Upgrade (Planned)                Reason Code: 0x80020003                Shutdown Type: restart                Comment:

WMI

wmic os get lastbootuptime

systeminfo

systeminfo | find "System Boot Time:"

Net Statistics

net stats srv

Note that in my testing of this method, the date was consistent with other methods above but time was not

Uptime

Powershell

Install

Install-Script -Name Get-ServerUptimeReport

Run

For a single server...

./Get-ServerUptimeReport.ps1 -ComputerName myServer

For multiple servers...

$servers = 'myServer1','myServer2'

foreach ($server in $servers) {

  Get-ServerUptimeReport.ps1 -ComputerName $server | Select-Object -Property *,@{n='ServerName';e={$server}}

}

Task Manager

Performance tab, CPU page