Quantcast
Channel: Powershell – TheITBros
Viewing all articles
Browse latest Browse all 91

How to Check Windows Uptime?

$
0
0
Check Windows Uptime

Uptime is the measure of the uninterrupted time that an operating system experiences since the last boot. Unlike Linux/Unix, Windows doesn’t have a native uptime command. On Windows, you can get the computer uptime value in several different ways: from the GUI, command prompt, or PowerShell. Let’s consider all methods on how to check Windows uptime.

Check Windows Uptime Using Task Manager

You can check the current Windows uptime value from the GUI. To do this, use the Task Manager.

  1. Press Ctrl + Shift + Esc to run the Task Manager;
  2. Click the Performance tab;
  3. The current uptime value is indicated in the Up time label (in this example, the computer didn’t reboot for 5 days).
    check windows uptime

Show Your Computer Uptime Using CMD

To get the uptime of a computer from the command prompt, you can use one of the methods below.
Run the command prompt as an administrator and execute the command:

systeminfo|FIND “System Boot Time”

The command should return the following response:

System Boot Time: 9/27/2019, 1:15:55 PM

windows uptime command

Also, you can get the uptime value using the built-in statistics of any system service that has been working non-stop since the system booted. These are typically server or workstation services. For example:

net statistics workstation |find “Statistics since”

Statistics since ?9/?27/?2019 1:16:18 PM

windows show uptime

Another way to get the Windows uptime is through WMI. The standard wmic utility is used:

wmic path Win32_OperatingSystem get LastBootUpTime

or

wmic path Win32_OperatingSystem get LastBootUpTime

LastBootUpTime

20190927131555.500000+120

check windows server uptime

To get uptime from a remote server/computer, use this command:

wmic /node:"lon-man01" os get lastbootuptime

check uptime windows 10

How to Check Windows Uptime Using PowerShell?

Now let’s look at ways to check uptime from PowerShell. Computer boot time is also can be requested through WMI:

Get-CimInstance Win32_OperatingSystem | Select-Object LastBootUpTime

windows server uptime command

Or you can get the date of the last OS boot in a more convenient form:

$wmi = Get-WmiObject Win32_OperatingSystem

$wmi.ConvertToDateTime($wmi.LastBootUpTime)

windows uptime command line

Friday, September 27, 2019 1:15:55 PM

To find out how many days your computer has been running without rebooting up to the current date, run:

(get-date) - (gcim Win32_OperatingSystem).LastBootUpTime

windows 10 check uptime

You got the computer up to the millisecond:

Days : 5

Hours : 20

Minutes : 15

Seconds : 11

Milliseconds : 256

Ticks : 5049112566859

TotalDays : 5.84388028571643

TotalHours : 140.253126857194

TotalMinutes : 8415.18761143167

TotalSeconds : 504911.2566859

TotalMilliseconds : 504911256.6859

Checking Windows Uptime Using Event Viewer

OS boot time can also be obtained from the Event Viewer. When the computer boots up, EventID 6005 appears in events (and the EventID 6005 when the Windows shuts down).

Open the Event Viewer > Windows Logs > System > right click > Filter current log > Event ID 6005 – Ok.

windows 10 uptime command

Open the last event (The Event log service was started). Computer boot time is indicated on its date.

find windows uptime

You can also get the time of this event from PowerShell:

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

powershell get system uptime

Get Uptime of Multiple Windows Computers in AD Domain with PowerShell

To find uptime across many computers (servers) in the AD domain you can use the following PowerShell script (we are using the Active Directory for Windows PowerShell module to get the computer list from a specific OU):

import-module activedirectory

$Servers = get-adcomputer -properties DNSHostName -Filter { enabled -eq "true" -and Operatingsystem -like "*Windows Server*" } -SearchBase ‘OU=Servers,OU=London,DC=corp,DC=theitbros,DC=com’

Foreach ($server in $Servers){

write-host $server.DNSHostName

Invoke-Command -ComputerName $server.DNSHostName -ScriptBlock { ("Uptime " + ((get-date) - (gcim Win32_OperatingSystem).LastBootUpTime).days) + " days" }

}

check windows 10 uptime

The post How to Check Windows Uptime? appeared first on TheITBros.


Viewing all articles
Browse latest Browse all 91

Trending Articles