Windows Server uptime is a standard metric that many server administrators use. In this post, you're going to learn how to check Windows Server uptime. And, since you're an IT ninja, I'll also show you how to find uptime across hundreds of servers at once and find the history of uptime for Windows!

Let's see how to find server uptime with a Windows Server admin's favorite tool, PowerShell.

By using a PowerShell script, you can poll as many servers as necessary. Not only that, but you can generate a fancy HTML report. Or perhaps export the results to a CSV file containing total uptime for each of your servers.

Finding a Single Windows Server Uptime

But first, we need to figure out how to capture the uptime on a single server.

There are many ways to get Windows server uptime without logging into every server. Don't do that!

You can use WMI, the registry, or the event log. The most accurate way to determine uptime is via the event log. Whenever a server starts up and shuts down, an event is generated inside of the System event log.

If you want a quick and dirty way to find uptime on a remote server without parsing the event log, you can also use the Get-Uptime command or go old school and use net stats srv.

By parsing the event log, you can find the start and end events that the server generates. You can then compare the two times to create a total uptime. Also, since many instances of these events are stored, we can query a history of uptimes!

Introducing the Get-ServerUptimeReport script

So you don't have to write the PowerShell yourself, download a community script called Get-ServerUptimeReport.ps1.

PS51> Install-Script -Name Get-ServerUptimeReport

This script allows you to provide a computer name as a parameter. It will then parse the System event log of the computer and find both a start and stop event to compare the two. It will then return the total time the server was online until the event log has rolled.

Below is an example of using this script on a server. It will return the total uptime for all of the events the server has in the event log, including the current uptime.

PS C:\> ./Get-ServerUptimeReport.ps1 -ComputerName sqlsrv1

Startup               Shutdown              Uptime (Days) Uptime (Min)
-------               --------              ------------- ------------
9/16/2017 12:40:00 PM 9/22/2017 4:20:11 PM           6.15      8860.18
9/16/2017 10:22:49 AM 9/16/2017 12:22:36 PM          0.08       119.79
9/16/2017 3:22:12 PM  9/22/2017 4:20:11 PM           6.04      8697.98

Finding Uptime Across Many Servers

This script is a quick way to find the uptime of a single server across many days. But what if you need this information for lots of servers at once? To do this, you can gather up a list of servers and then pass each computer name, one at a time, to this script.

As an example, define all your servers in an array in the PowerShell console. I'll call mine $servers.

In reality though, you might be pulling server names from Active Directory, Hyper-V, or a text file. As long as you can build an array of server names, you're fine.

Define all the server names and then iterate over each one with a loop, as shown below.

$servers = 'WEBSRV1','SQLSRV1'
foreach ($server in $servers) {
    Get-ServerUptimeReport.ps1 -ComputerName $server

Startup               Shutdown              Uptime (Days) Uptime (Min)
-------               --------              ------------- ------------
9/16/2017 12:45:48 PM 9/22/2017 4:25:39 PM           6.15      8859.86
9/16/2017 10:42:52 AM 9/16/2017 12:42:34 PM          0.08        119.7
9/16/2017 2:42:17 PM  9/22/2017 4:25:39 PM           6.07      8743.38
9/16/2017 12:40:00 PM 9/22/2017 4:25:39 PM           6.16      8865.65
9/16/2017 10:22:49 AM 9/16/2017 12:22:36 PM          0.08       119.79
9/16/2017 3:22:12 PM  9/22/2017 4:25:39 PM           6.04      8703.46

This code works, but you can't determine which server each row references. Add a server name to the output like below using a calculated property.

$servers = 'WEBSRV1','SQLSRV1'
foreach ($server in $servers) {
    Get-ServerUptimeReport.ps1 -ComputerName $server | Select-Object -Property *,@{n='ServerName';e={$server}}

Startup               Shutdown              Uptime (Days) Uptime (Min) ServerName
-------               --------              ------------- ------------ ----------
9/16/2017 12:45:48 PM 9/22/2017 4:34:59 PM           6.16      8869.19 WEBSRV1
9/16/2017 10:42:52 AM 9/16/2017 12:42:34 PM          0.08        119.7 WEBSRV1
9/16/2017 2:42:17 PM  9/22/2017 4:34:59 PM           6.08      8752.71 WEBSRV1

Startup               Shutdown              Uptime (Days) Uptime (Min) ServerName
-------               --------              ------------- ------------ ----------
9/16/2017 12:40:00 PM 9/22/2017 4:35:01 PM           6.16      8875.01 SQLSRV1
9/16/2017 10:22:49 AM 9/16/2017 12:22:36 PM          0.08       119.79 SQLSRV1
9/16/2017 3:22:12 PM  9/22/2017 4:35:01 PM           6.05      8712.81 SQLSRV1

We now have an excellent little tool that can provide us a quick report on uptime for our servers over time!


Using a pre-built community PowerShell check, you can easily find Windows Server uptime across one, 100 or 1,000 Windows Servers at once!

Further Reading

Join the Jar Tippers on Patreon

It takes a lot of time to write detailed blog posts like this one. In a single-income family, this blog is one way I depend on to keep the lights on. I'd be eternally grateful if you could become a Patreon patron today!

Become a Patron!