Measuring Reboot Time With PowerShell

In enterprise environments, you will usually find an array of different Windows operating systems, hardware and of course software. Typically, machines are managed and configured with group policy and SCCM, or perhaps other more modern methods like Chef or Puppet. One of the symptoms of an unhealthy Windows computer is the amount of time it takes to boot up.

Longer boot times can mean hardware is failing, such as slow hard disks. Or perhaps, there is a group policy that is holding up the process of getting to the login screen. In this article, I will show how you can use PowerShell to measure the number of seconds a computer(s) takes to go from shutting down and starting up.

Measure-RebootTime Command

A while back, we had a fleet of machines that users were complaining about. The issue was that certain machines were taking a long time to reboot, some even 15 minutes. Since these machines are not used at certain hours or days, I decided to create a PowerShell function to reboot a bunch and measure their reboot time. That is why I created Measure-RebootTime that includes a helper function Get-RebootTime.

The Get-RebootTime function itself is very simple. It used Measure-Command to measure using Restart-Computer while also waiting for PowerShell (WMI) to be available for remote connection. I also set a timeout of 1200 seconds. I then round the seconds to two decimals and throw it into a PSCustomObject.

$Time = Measure-Command {

    Restart-Computer -ComputerName $ComputerName -Wait -For powershell -Timeout 1200 -ErrorAction Stop

} | Select-Object -ExpandProperty TotalSeconds

$RoundedTime = [math]::Round($Time,2)


    ComputerName = $ComputerName

    Seconds = $RoundedTime



Comments are closed.