How to find computer's uptime/boot time by command & script?

Article Index

Many methods are available to get the system or system uptime or boot time. You can get this from a single command, GUI and from a PowerShell script for get uptime for multiple servers in a file.

Method 1 -This is the most easy way and get information quickly as compare to other method.

Step 1 - Open command prompt and type “net statistics server” or “net stats srv” and press Enter,

You will get date and time since server is up in line of Statistics since.

 

Method 2 - By System Information command. This will take few second to first get complete system information then search for boot time and show one line result.

Step 1 - Open command prompt and typesysteminfo | find "System Boot Time:"

 

Method 3 -From Uptime utility.

Step 1 - Download uptime.exe tool from click here. And save it in a folder.

Step 2 - Open command prompt and go to this folder directory and type “uptime


Method 4 - From Event Viewer.

Step 1 - Open Event viewer from computer management or open Run and type “eventvwr

Step 2 - Expand Windows logs and select system.

Step 3 - Click on Filter Current Log.. from right action panel. And type 6005 in field - <All Event IDs>

Step 4 - See latest log date and time, This date and time is the system boot time/uptime since.

 

Method 5 -You can also get this from WMI scripting. See below microsoft link for details.

https://blogs.technet.microsoft.com/heyscriptingguy/2005/08/02/how-can-i-determine-the-uptime-for-a-server/

 

Method 6 -From Powershell scripting, ANd here you can get uptime information, When you need for many server, And uptime will generate in a txt file.

Step 1 - Download uptime.ps1 by click here, Or use below script code and create a .ps1 file and put this in a folder. Here for example making a folder name - UptimeReport in C: drive

Script code -

$serverlist = "C:\uptimereport\serverlist.txt"

$reporttextfile = "C:\uptimereport\uptime.txt"

out-file -filepath $reporttextfile -append -InputObject ("Uptime Report Run " + (Get-Date))

foreach ($server in Get-Content s1.txt)

{

$ping = gwmi win32_pingstatus -f "Address = '$server'"

if($ping.statuscode -eq 0)

{

   $wmi = Get-WmiObject -ComputerName $server -Query "SELECT LastBootUpTime FROM Win32_OperatingSystem"    

   $now = Get-Date    

   $boottime = $wmi.ConvertToDateTime($wmi.LastBootUpTime)

   out-file -filepath $reporttextfile -append -InputObject ("Uptime for " + $server + ": " + ($now - $boottime))

}

else

{

   out-file -filepath $reporttextfile -append -InputObject ("Uptime for " + $server + ": Host offline")

}

}

Step 2 - Edit some lines from above script.

Change “C:\uptimereport\serverlist.txt” path to your server list file path, in which .txt file you can put multiple server list in below format.

Net-Server01

Net-ServerDC02

Net-SQLRS01

 

Change “C:\uptimereport\uptime.txt” path to your result file path, Where you can get uptime report of all your server.

Step 3 - Open PowerShell and run the .ps1 file then you will get your all server uptime report in above path of step 2 line 2.

Keyword - How to find Windows uptime?, How to Find Your Computer's Uptime and Installation Date, How to get the uptime in windows, How to Find the Uptime or Boot Time of a Server, How to find the system uptime in a Windows Server, Command line - How to find out uptime on Windows, Find server uptime in bulk by powershell, Powershell script to known multiple server uptime, Find system uptime on Server 2012, How To Check Your System's Uptime In Windows 7 | Vista | XP, Find Your Uptime in Windows Server 2008 / R2, Finding the Uptime of Windows Server 2008, Windows 10: How to See System Uptime