1.11.2019

Windows'da kapanma olaylarının takibi

Beklenmeyen kapanma. En çok merak edilen konulardan birisi. Evde veya işte, kişisel bilgisayar veya sunucu. Soru hep aynı. Neden kapanmış?

Aşağıdaki olayları bilgisayarın açılış ve kapanış saatlerini ve hatta nedenlerini görüntülemek için kullanabiliriz (hepsi System evenlog'da).

Event ID Source Message
6005EventlogThe Event log service was started.
6006EventlogThe Event log service was stopped.
6008EventlogThe previous system shutdown at <date time> was unexpected.
6009EventlogMicrosoft (R) Windows (R) 10.00. 19042 Service Pack 1 Multiprocessor Free.
(Sistemin açışında sürüm bilgisinin kaydını düşen bir olay. 6005, 6006 ve 6009 olayları aynı anda kayda düşmüş gibi gözükür)
6013EventlogThe system uptime is <seconds> seconds.
(Aslında açılış ve kapanışla ilgisi yok, sistemin kaç saniyedir açık olduğunu bildiren periyodik bir kayıt)
1074User32The process <process> (<computer>) has initiated the power off of computer <computer> on behalf of use
 <username> for the following reason: Other (Unplanned)
12Kernel-GeneralThe operating system started at system time <date time>
13Kernel-GeneralThe operating system is shuting down at system time <date time>
109Kernel-PowerThe kernel power manager has initiated a shutdown transition.
107Kernel-PowerThe system has resumed from sleep. (fast boot etkin olan Windows 10 sistemlerde kapanma yerine)
1Kernel-GeneralThe system time has changed to <datetime> from <datetime>.
Change Reason: System time synchronized with the hardware clock. (fast boot etkin olan Windows 10 sistemlerde açılma yerine)
42Kernel-PowerThe system is entering sleep.
Sleep Reason: Application API
41Kernel-PowerThe system has rebooted without cleanly shutting down first. This error could be caused if the system stopped responding, crashed, or lost power unexpectedly.
1Power Troubleshooter    
The system has returned from a low power state.
Sleep Time: ...
Wake Time: ....... (42/Kernel-Power olayı ile düşük güç moduna girmek ve bu olayla çıkmak)
19WindowsUpdateClientInstallation Successful: Windows successfully installed the following update... (tekrar başlatma gerekmeyen durumlarda)
20WindowsUpdateClientInstallation Failure: Windows failed to install the following update...
21WindowsUpdateClientRestart Required: To complete the installation of the following updates, the computer must be restarted. Until this...
22WindowsUpdateClientRestart Required: To complete the installation of the following updates, the computer will be restarted within 15 minutes...
27WindowsUpdateClientAutomatic Updates is now paused. (güncelleştirmelerin ardından yeniden başlatılana kadar hizmet durdurulur)
43WindowsUpdateClientInstallation Started: Windows has started installing the following update...
44WindowsUpdateClientWindows Update started downloading an update.
26Application PopupBir uygulamanın hata verdmesi veya kaldırılması sebebiyle tekrar başlatma gerektiğini bildiren çeşitli mesajlar    
1000-1002    
Application Error Bir uygulama beklenmeyen bir şekilde kapandığında. (bu olay Application Event Log'a yazılır)


İlk 3 sırada listelenen 6005, 6006 ve 6008 olaylarının kaynağı neden eventlog? Çünkü bilgisayar düzgün bir şekilde başlatılırken ilk başlayan hizmet eventlog, düzgün kapanırken de en son durdurulan hizmet de eventlog hizmetidir. Ancak çalışma süresi boyunca bu hizmetler durdurulup tekrar başlatılabileceği için dikkatli davranmak gerekebilir.

Beklenmeyen bir kapanmayı (güç kesintisi, donanım arızası gibi) ile ilgili 6008/Eventlog, 1024/User32 ve 41/Kernel-Power olayları aranabilir.

Son 2 satırda yer alan 21/Windows Update Agent ve 26/Application Popup olayları ise tekrar başlatmanın kendisine değil, muhtemel sebebine dair bir bilgi içerebilir.

Powershell Get-WinEvent kullanarak sorgularken ProviderName olarak WindowsUpdateClient yerine ya "Microsoft-Windows-WindowsUpdateClient" yazmak, ya da "*WindowsUpdateClient" şeklinde wildcard kullanmak gerekir. Örneğin:
Get-WinEvent -ComputerName <bilgisayar> -FilterHashTable @{LogName="System";ProviderName="*WindowsUpdateClient"} -MaxEvents 10

Birkaç olay ID'sini ve sağlayıcı ismini bir arada kullanarak şu şekilde bir komut son 10 günde olup bitene göz atmak için faydalı olabilir.

Get-WinEvent -FilterHashTable @{LogName="System";ProviderName=("Microsoft-Windows-WindowsUpdateClient","User32","Microsoft-Windows-Kernel-General");Id=12,13,19,20,21,22,43,44,1074;StartTime=(Get-Date).AddDays(-10)} |Select TimeCreated, Id, Message |Format-Table -AutoSize -Wrap

Event ID'leri ile sınırlamadan, örneğin son 2 saatteki geniş bir olay zincirini incelemek için

Get-WinEvent -FilterHashTable @{LogName="System";ProviderName=("Microsoft-Windows-WindowsUpdateClient","User32","Microsoft-Windows-Kernel-General","Microsoft-Windows-Kernel-Power","Microsoft-Windows-Power-Troubleshooter");StartTime=(Get-Date).AddHours(-2)} |Select TimeCreated, Id, Message |Format-Table -AutoSize -Wrap