Reboot time in seconds or minutes - Windows server

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:

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

-Really appreciate your answer

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.

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?

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.

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.

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 is built on rebooting the servers when you execute the script.

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

Your requirement sounds a little weird though. You actually want to swim but you don’t like to get wet!?! :face_with_raised_eyebrow: :thinking: :smirk: :smirk:

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.

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

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…

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.

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. :wink:

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)

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.

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 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?

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.

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.

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

    Oldest = $true

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

            ShutdownTimestamp = $stopped
            StartupTimestamp  = $_.timecreated
            TotalSeconds      = $total

        Remove-Variable started,stopped,total -ErrorAction SilentlyContinue

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

1 Like