# Reboot time in seconds or minutes - Windows server

**URL:** <https://forums.powershell.org/t/reboot-time-in-seconds-or-minutes-windows-server/17243>\
**Category:** PowerShell Help\
**Created:** [August 6, 2021, 8:03am UTC](https://forums.powershell.org/t/reboot-time-in-seconds-or-minutes-windows-server/17243 "2021-08-06T08:03:24Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![bit-101](https://avatars.discourse-cdn.com/v4/letter/b/b77776/32.png) [@bit-101](https://forums.powershell.org/u/bit-101)\
**Post date:** [August 6, 2021, 8:03am UTC](https://forums.powershell.org/t/reboot-time-in-seconds-or-minutes-windows-server/17243/1 "2021-08-06T08:03:24Z")

</div>

Hope this is the right forum?  
I have a bunch of windows servers and want to show how long the reboot was take for each server. I dont want to reboot again, I want to check afterwards how long a windows server reboot was take.  
This was the only exeample I found with Powershell:

> **[Measuring Reboot Time with PowerShell - Ipswitch](https://www.ipswitch.com/blog/measuring-reboot-time-with-powershell)**
>
> One of the symptoms of an unhealthy Windows computer is the amount of time it takes to boot up.

But I dont want to reboot the servers when I´m execute the script.

-Anyone?  
-Really appreciate your answer

---

<div class="post-metadata">

**Author:** ![Olaf](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/olaf/32/992_2.png) [@Olaf](https://forums.powershell.org/u/Olaf)\
**Post date:** [August 6, 2021, 12:41pm UTC](https://forums.powershell.org/t/reboot-time-in-seconds-or-minutes-windows-server/17243/2 "2021-08-06T12:41:16Z")

</div>

Just an idea - you could try to find event log entries indicating shutdown and startup and use this to calculate the time the computer needed to reboot.

---

<div class="post-metadata">

**Author:** ![jlogan3o13](https://avatars.discourse-cdn.com/v4/letter/j/e68b1a/32.png) [@jlogan3o13](https://forums.powershell.org/u/jlogan3o13)\
**Post date:** [August 6, 2021, 7:59pm UTC](https://forums.powershell.org/t/reboot-time-in-seconds-or-minutes-windows-server/17243/3 "2021-08-06T19:59:59Z")

</div>

I use something similar to reboot several hundred servers in our VMWare environment, so I know the code in that article works. What problem, exactly, are you having with it?

---

<div class="post-metadata">

**Author:** ![tonyd](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/tonyd/32/1041_2.png) [@tonyd](https://forums.powershell.org/u/tonyd)\
**Post date:** [August 6, 2021, 11:55pm UTC](https://forums.powershell.org/t/reboot-time-in-seconds-or-minutes-windows-server/17243/4 "2021-08-06T23:55:34Z")

</div>

Does anyone else see the irony here? You want to measure reboot times, but you dont want to reboot? How then would you expect the script run with accurate data?

Maybe this will help? Not a scripted solution, but part of Windows.

> **[Exercise 1 - Evaluate Fast Startup Using the Assessment Toolkit](https://docs.microsoft.com/en-us/windows-hardware/test/wpt/optimizing-performance-and-responsiveness-exercise-1)**
>
> Boot time is a common benchmark that is often used to measure Windows performance. Over the lifetime of a system, longer boot times can be an indicator of system problems such as inefficient configuration, device conflicts, and malware.

---

<div class="post-metadata">

**Author:** ![bit-101](https://avatars.discourse-cdn.com/v4/letter/b/b77776/32.png) [@bit-101](https://forums.powershell.org/u/bit-101)\
**Post date:** [August 7, 2021, 5:30am UTC](https://forums.powershell.org/t/reboot-time-in-seconds-or-minutes-windows-server/17243/5 "2021-08-07T05:30:02Z")

</div>

@tonyd  
The reboot takes place at night and must not disturb any user.  
And I want to be able to check the start-up time afterwards on the day.

I must not in any way influence the major reboot script that runs at night.

---

<div class="post-metadata">

**Author:** ![bit-101](https://avatars.discourse-cdn.com/v4/letter/b/b77776/32.png) [@bit-101](https://forums.powershell.org/u/bit-101)\
**Post date:** [August 7, 2021, 5:40am UTC](https://forums.powershell.org/t/reboot-time-in-seconds-or-minutes-windows-server/17243/6 "2021-08-07T05:40:31Z")

</div>

@jlogan3o13  
The reboot takes place at night and must not disturb any user.  
And I want to be able to check the start-up time afterwards on the day.

I must not in any way influence the major reboot script that runs at night.

In other words I try to get the time for restart at night and can not reboot the servers during the day.

I have to somehow read the values ​​from the night’s reboot.

This example script:  
[Measuring Reboot Time with PowerShell - Ipswitch](https://blog.ipswitch.com/measuring-reboot-time-with-powershell) **is built on rebooting the servers** when you execute the script.

---

<div class="post-metadata">

**Author:** ![bit-101](https://avatars.discourse-cdn.com/v4/letter/b/b77776/32.png) [@bit-101](https://forums.powershell.org/u/bit-101)\
**Post date:** [August 7, 2021, 5:48am UTC](https://forums.powershell.org/t/reboot-time-in-seconds-or-minutes-windows-server/17243/7 "2021-08-07T05:48:25Z")

</div>

@Olaf  
Tanks, it seems to be the only way to solve the problem when have to mesaure the reboot time afterwards?

---

<div class="post-metadata">

**Author:** ![Olaf](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/olaf/32/992_2.png) [@Olaf](https://forums.powershell.org/u/Olaf)\
**Post date:** [August 7, 2021, 7:05am UTC](https://forums.powershell.org/t/reboot-time-in-seconds-or-minutes-windows-server/17243/8 "2021-08-07T07:05:43Z")

</div>

Your requirement sounds a little weird though. You actually want to swim but you don’t like to get wet!?! 🤨 🤔 😏 😏

If you already have a script in place to trigger the reboot why not using this and extending it with the additional functionality? If it’s not your responsibility you might speak with the adccording colleagues and discuss a solution fitting both requirements.

If you insist on not interfering with an existing script you have to use data Windows already collects such as eventlog entries or registry values or WMI data.

If you already know when the server gets restarted from the script you seem to have in place already the simplest solution would be to get LastBootupTime with CIM and calculate the difference.

```auto
Get-CimInstance -ClassName CIM_OperatingSystem -ComputerName 'RemoteComputer' | 
    Select-Object -Property CSName, LastBootUpTime

```

---

<div class="post-metadata">

**Author:** ![bit-101](https://avatars.discourse-cdn.com/v4/letter/b/b77776/32.png) [@bit-101](https://forums.powershell.org/u/bit-101)\
**Post date:** [August 7, 2021, 4:38pm UTC](https://forums.powershell.org/t/reboot-time-in-seconds-or-minutes-windows-server/17243/9 "2021-08-07T16:38:39Z")

</div>

Thanks again, but another problem is that neither event 1074, 6005 nor 12 are displayed in the event viewer after the night reboot.  
-But the most important reboot script (at night) is completely out of my reach.  
The best thing is to try to solve or contribute with tips to solve it under the prevailing circumstances and not ask question why. It just sucks energy when you already exhausted.  
-I really appreciate answers like yours, it keeps colleagues move forward…

---

<div class="post-metadata">

**Author:** ![tonyd](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/tonyd/32/1041_2.png) [@tonyd](https://forums.powershell.org/u/tonyd)\
**Post date:** [August 7, 2021, 4:41pm UTC](https://forums.powershell.org/t/reboot-time-in-seconds-or-minutes-windows-server/17243/10 "2021-08-07T16:41:11Z")

</div>

Hmm … did you even look at the link I posted? From what I understand reading this post, it will give you exactly what you want without any scripts or forced reboots.

---

<div class="post-metadata">

**Author:** ![Olaf](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/olaf/32/992_2.png) [@Olaf](https://forums.powershell.org/u/Olaf)\
**Post date:** [August 7, 2021, 5:26pm UTC](https://forums.powershell.org/t/reboot-time-in-seconds-or-minutes-windows-server/17243/11 "2021-08-07T17:26:26Z")

</div>

> [@bit-101](#):
>
> neither event 1074, 6005 nor 12 are displayed in the event viewer after the night reboot.

I don’t know exactly what the event IDs 1074 and 12 stands for but as far as I know represents the event ID 6005 the start of the event log service and the event ID 6006 the stop of the event log service.  
I think it would be pretty unlikely that your servers do not run the event log service.

So on standard Windows systems it should be possible to query the event log for the events 6005 and 6006 and calculate the time span between those two events. That would deliver either the uptime or the time needed to restart the system.

At least it should be enough to collect data suitable for comparison between servers or between different time stamps. 😉

---

<div class="post-metadata">

**Author:** ![bit-101](https://avatars.discourse-cdn.com/v4/letter/b/b77776/32.png) [@bit-101](https://forums.powershell.org/u/bit-101)\
**Post date:** [August 8, 2021, 2:53pm UTC](https://forums.powershell.org/t/reboot-time-in-seconds-or-minutes-windows-server/17243/12 "2021-08-08T14:53:46Z")

</div>

As I mentioned before 1074, 6006, 6005, 12 are not present in the event log viewer.  
Could it depend of these events are only present with a normal shutdown and normal start.  
Not with reboot?  
If so, the problem is what should I compare _LastBootUpTime_ with to calculate the amount of time for each server reboot? That’s the problem.  
(Get-CimInstance -ClassName Win32\_OperatingSystem | Select-Object -Property LastBootUpTime)

---

<div class="post-metadata">

**Author:** ![Olaf](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/olaf/32/992_2.png) [@Olaf](https://forums.powershell.org/u/Olaf)\
**Post date:** [August 8, 2021, 3:18pm UTC](https://forums.powershell.org/t/reboot-time-in-seconds-or-minutes-windows-server/17243/13 "2021-08-08T15:18:45Z")

</div>

> [@bit-101](#):
>
> Could it depend of these events are only present with a normal shutdown and normal start.  
> Not with reboot?

If we are talking about Windows Servers - No. If you don’t have these events on your servers you might have other more general problems you should solve first.

> [@bit-101](#):
>
> what should I compare

That depends pretty much on what exactly you want to compare it. If you use the event IDs 12 and 13 you pretty much have the time the hardware needs to reboot (the BIOS and [POST](https://en.wikipedia.org/wiki/Power-on_self-test) stuff). Because they are one of the first events on a start and one of the last events on a shutdown a Windows server logs.

If you want to measure how long Windows takes to reboot including drivers and most of the services you should pick a service who ist almost first to shutdown for a reboot and is almost last to come up again after the reboot.

May I ask what your job is in your company? Are you an IT admin or an intern or an apprentice?

---

<div class="post-metadata">

**Author:** ![bit-101](https://avatars.discourse-cdn.com/v4/letter/b/b77776/32.png) [@bit-101](https://forums.powershell.org/u/bit-101)\
**Post date:** [August 8, 2021, 5:29pm UTC](https://forums.powershell.org/t/reboot-time-in-seconds-or-minutes-windows-server/17243/14 "2021-08-08T17:29:26Z")

</div>

I’m a student at university. Now I has got some real cases to solve to complete my exam.  
But anyway, these events are still not present with a scripted reboot.  
Only if I manually Shut down and Start up these servers. I haven’t checked on all servers  
opereativ version yet. It´s virtual servers.

---

<div class="post-metadata">

**Author:** ![krzydoug](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/krzydoug/32/1008_2.png) [@krzydoug](https://forums.powershell.org/u/krzydoug)\
**Post date:** [August 9, 2021, 6:56pm UTC](https://forums.powershell.org/t/reboot-time-in-seconds-or-minutes-windows-server/17243/15 "2021-08-09T18:56:46Z")

</div>

> [@bit-101](#):
>
> But anyway, these events are still not present with a scripted reboot.

In which way are you scripting this? I’ve confirmed powershell’s Restart-Computer, shutdown.exe, and scheduled task all result in the eventlog entries. That is a function of windows itself when gracefully shutting down and start. I would assume you have a configuration issue or maybe filtering these out if you can’t see them/they aren’t created. On all normally functioning Windows machines, the following code will measure the reboot time in seconds based on the 6005/6006 eventlog entries.

```auto
$params = @{
    FilterHashtable = @{
        Logname = 'System'
        ID = 6005,6006
        ProviderName = 'Eventlog'
    }

    Oldest = $true
}

switch (Get-WinEvent @params){
    {$_.id -eq 6005} {
        
        if(!$stopped){            
            $stopped = 'No related shutdown event found'
            $total = 'N/A'
        }
        else{
            [float]$total = "{0:n2}" -f ($_.timecreated - $stopped).totalseconds
        }

        [PSCustomObject]@{
            ShutdownTimestamp = $stopped
            StartupTimestamp = $_.timecreated
            TotalSeconds = $total
        }

        Remove-Variable started,stopped,total -ErrorAction SilentlyContinue
    }

    {$_.id -eq 6006} {
        $stopped = $_.timecreated
    }
}

```

---

<div class="post-metadata">

**Author:** ![dotnVo](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dotnVo](https://forums.powershell.org/u/dotnVo)\
**Post date:** [May 16, 2024, 8:22pm UTC](https://forums.powershell.org/t/reboot-time-in-seconds-or-minutes-windows-server/17243/16 "2024-05-16T20:22:00Z")

</div>


