Audit process creation events

Using standard Windows auditing mechanisms, you can log all process creation events. This also works in the Home editions of Windows.

  1. Enable auditing for process creation events:
    %windir%\system32\auditpol.exe /set /subcategory:"Process Creation" /success:enable /failure:enable
  2. Enable the Include command line in process creation events feature:
    Windows Registry Editor Version 5.00

Every log message will contain this very verbose explanation:

Token Elevation Type indicates the type of token that was assigned to the new process in accordance with User Account Control policy.

Type 1 is a full token with no privileges removed or groups disabled.  A full token is only used if User Account Control is disabled or if the user is the built-in Administrator account or a service account.

Type 2 is an elevated token with no privileges removed or groups disabled.  An elevated token is used when User Account Control is enabled and the user chooses to start the program using Run as administrator.  An elevated token is also used when an application is configured to always require administrative privilege or to always require maximum privilege, and the user is a member of the Administrators group.

Type 3 is a limited token with administrative privileges removed and administrative groups disabled.  The limited token is used when User Account Control is enabled, the application does not require administrative privilege, and the user does not choose to start the program using Run as administrator.

This is particularly distracting when querying the event log from PowerShell. This PowerShell function therefore removes this explanation from each message:

function Get-ProcessAuditEvents {

    function Prettify( [string] $Message ) {

        $Message = [regex]::Replace( $Message, '(\s+)Token Elevation Type indicates(.+)$', '', 'Singleline' );
        $Message = [regex]::Replace( $Message, '(Token Elevation Type:\s+%%1936)', '$1 (Full token)' );
        $Message = [regex]::Replace( $Message, '(Token Elevation Type:\s+%%1937)', '$1 (Elevated token)' );
        $Message = [regex]::Replace( $Message, '(Token Elevation Type:\s+%%1938)', '$1 (Limited token)' );
        $Message = [regex]::Replace( $Message, '(Process ID:\s+)(0x[a-f0-9]+)', { 
            return '{0}{1}' -f @(
                [System.Convert]::ToInt32( $Match.Groups[2].Value, 16 )
        return $Message;

    Get-WinEvent -MaxEvents $MaxEvents -FilterHashtable @{
        LogName = 'Security';
        Id = 4688;
    } | Sort-Object -Property TimeCreated | ForEach-Object {
        [pscustomobject] @{
            TimeCreated = $_.TimeCreated.ToUniversalTime().ToString('u');
            Message     = Prettify $_.Message;

Additionally, the function will convert hexadecimal process IDs to the more familiar decimal notation. Use the function as follows:

PS> Get-ProcessAuditEvents -MaxEvents 1 | Format-List

TimeCreated : 2021-04-29 10:48:38
Message     : A new process has been created.

              Creator Subject:
                Security ID:            S-1-5-21-574766472-1934979887-525962139-1002
                Account Name:           Christoph
                Account Domain:         DESKTOP-BHAKPDJ
                Logon ID:               0x5EF73

              Target Subject:
                Security ID:            S-1-0-0
                Account Name:           -
                Account Domain:         -
                Logon ID:               0x0

              Process Information:
                New Process ID:         16936
                New Process Name:       C:\Windows\System32\notepad.exe
                Token Elevation Type:   %%1936 (Full token)
                Mandatory Label:                S-1-16-8192
                Creator Process ID:     13096
                Creator Process Name:   C:\Windows\System32\cmd.exe
                Process Command Line:   notepad.exe  c:\windows\system32\drivers\etc\hosts

You can also easily filter the events:

PS> Get-ProcessAuditEvents | Where-Object -Property Message -Match notepad | Format-List