Event ID 4647: user-initiated logoff
What Event ID 4647 (user-initiated logoff) means, the fields to check, what is normal and what is suspicious, with PowerShell and KQL queries to find it.
Event ID 4647 is written when a user starts the logoff themselves, from the Start menu or with logoff. It only applies to interactive and RDP sessions. Comparing 4647 with 4634 tells you whether the user signed out deliberately.
The fields that matter
| Field | What it tells you |
|---|---|
| Subject > Account Name | Who logged off. |
| Logon ID | Links to the 4624 that started the session. |
What is normal
Users signing out at the end of a session.
When Event ID 4647 is suspicious
- An admin account signing out of a server it was never meant to be on, which confirms an interactive session.
Common false positive: Normal behaviour.
Find Event ID 4647 with PowerShell
Get-WinEvent -FilterHashtable @{LogName='Security'; Id=4647; StartTime=(Get-Date).AddDays(-7)} -MaxEvents 50 |
ForEach-Object {
$d = [ordered]@{ Time = $_.TimeCreated; Computer = $_.MachineName }
([xml]$_.ToXml()).Event.EventData.Data | ForEach-Object { $d[$_.Name] = $_.'#text' }
[pscustomobject]$d
} | Format-List
Microsoft Sentinel (KQL)
SecurityEvent
| where TimeGenerated > ago(7d) and EventID == 4647
| project TimeGenerated, Computer, Account, Activity, EventData
| order by TimeGenerated desc
Related events
- Event ID 4634: Logoff
- Event ID 4624: Successful logon
- Event ID 4779: Session disconnected from a window station
FAQ
What is the difference between 4647 and 4634?
4647 says the user asked to log off. 4634 is written when the session actually ends, whatever the reason.
Windows Event Triage reads a CSV, EVTX-to-JSON or XML export in your browser and flags brute force, new admins, suspicious services and log clearing.
IOC Triage, our free browser extension: right-click it for a verdict from 15 threat-intel sources, then copy a ready ticket note.