logo powershell

Restart redenen achterhalen via powershell

Powershell biedt uitkomst wanneer je op zoek bent naar restart-events.

Get-EventLog -LogName System |? {$_.EventID -in (6005,6006,6008,6009,1074,1076)} | ft TimeGenerated,EventId,Message -AutoSize -wrap

the following reason: Operating System: Service pack (Planned) > Windows Update

the following reason: No title for this reason could be found komt door de niet zo nette restart taak shutdown.exe /r /f een nettere variant is :

shutdown.exe /r /f /t 10 /c "Periodic Restart"

Of wanneer je een echte shutdown inplant (waarbij je jezelf 6min tijd geeft om via de laatste machine de firewall ook een shutdown te geven 😉 ):

shutdown.exe /s /f /t 360 /c "Powergrid Maintenance"