Find-Uptime :: Powershell script to find uptime of remote computers

System administrators often used to find uptime of computers for various weekly or monthly reports and presentations. There are various commands and third party tools to find uptime of computers.

Here in this article we used PowerShell script to find uptime of bulk remote computers. All you need to have is the hostname or IP address details of the computers saved in the notepad text file.

Powershell script to find uptime of remote computers:

We used Get-Content along with the Read-Host cmdlet to read the inputs from the text file and assign the inputs to variable called .

Once you have the computer detail all we need to do is to validate whether the device is reachable or not so here we used Test-Connection cmdlet to validate the ping status and assigned the output to the variable $Pingcheck

In few cases the ping status will return success but the computer will not be reachable, so here we used one more validation to confirm the computer reachability by checking administrative shares of the computers using Test-Patch cmdlet.

Once we have all performed all these operation we come to our final step to find uptime, here we used WMI class cmdlets to fetch the uptime of the computers by passing the –ComputerName parameter.

We also used expression ConverttoDateTime to convert the date & time to readable format.

Now we have all the details that are required for us to find uptime, all we need to do is combine the cmdlets that we listed into a single script inside simple function like mentioned below.


Copy this script to the notepad file and save it with extension PS1 and execute to find the uptime of the computers that you need.

Once the script is executed the output will be listed as mentioned in the below image.

Hope this article helps, execute this script in test environment before implementing in production. use this script at your own risk as we do not provide any guarantee or warranty for any loss occurred.