NTEventLogEventConsumer

NTEvent Log Event Consumer

The NTEventLogEventConsumer class logs a specific message to the operating system event log when an event is delivered to it.

On this page

Main example

List instances

# All instances of NTEventLogEventConsumer, with the main properties
Get-CimInstance -ClassName NTEventLogEventConsumer -Namespace 'root/subscription' |
    Select-Object -Property Name, Category, EventID, EventType

Examples

Filter with WQL

# WQL filter evaluated by the provider: names starting with "a" (the WQL wildcard is %)
$cimParameters = @{
    ClassName = 'NTEventLogEventConsumer'
    Namespace = 'root/subscription'
    Filter    = "Name LIKE 'a%'"
}
Get-CimInstance @cimParameters |
    Select-Object -Property Name, Category, EventID, EventType

The filter is evaluated by the WMI provider: less data is transferred than with Where-Object.

Query a remote computer (CIM session)

review before running
# Name of the remote computer
$computerName = 'SERVER01'
# The CIM session (WSMan by default) can be reused for several queries
$cimSession = New-CimSession -ComputerName $computerName
try {
    $cimParameters = @{
        CimSession = $cimSession
        ClassName  = 'NTEventLogEventConsumer'
        Namespace  = 'root/subscription'
    }
    Get-CimInstance @cimParameters |
        Select-Object -Property Name, Category, EventID, EventType
} finally {
    Remove-CimSession -CimSession $cimSession
}

WSMan (WinRM) is used by default. For a host without WinRM, create the session with -SessionOption (New-CimSessionOption -Protocol Dcom). Add -Credential to use another account.

Show the class structure

# Class structure: properties, types and flags (Key, ReadOnly…)
$cimClass = Get-CimClass -ClassName NTEventLogEventConsumer -Namespace 'root/subscription'
$cimClass.CimClassProperties |
    Select-Object -Property Name, CimType, Flags

Properties

13 of 13 properties
NameTypeAccessDescription
Categoryuint16read

Event category. This is source-specific information and can have any value.

Code
# Value of Category for each instance
$cimParameters = @{
    ClassName = 'NTEventLogEventConsumer'
    Namespace = 'root/subscription'
    Property  = @('Name', 'Category')
}
Get-CimInstance @cimParameters |
    Select-Object -Property Name, Category
CreatorSIDuint8[]read

Security identifier (SID) that uniquely identifies the user who creates a filter. WMI stores the SID of the user who creates an instance of __EventConsumer or the Administrator SID, depending on the operating system. For more information, see Binding an Event Filter with a Logical Consumer and Monitoring and Responding to Events with Standard Consumers.

Code
# Value of CreatorSID for each instance
# CreatorSID is an array: -ExpandProperty returns its items one by one
$cimParameters = @{
    ClassName = 'NTEventLogEventConsumer'
    Namespace = 'root/subscription'
    Property  = 'CreatorSID'
}
Get-CimInstance @cimParameters |
    Select-Object -ExpandProperty CreatorSID
EventIDuint32read

Event message in the message DLL. This property cannot be NULL.

Code
# Value of EventID for each instance
$cimParameters = @{
    ClassName = 'NTEventLogEventConsumer'
    Namespace = 'root/subscription'
    Property  = @('Name', 'EventID')
}
Get-CimInstance @cimParameters |
    Select-Object -Property Name, EventID
EventTypeuint32read

Type of event. This parameter can have one of the values listed in the following list, which are defined in Winnt.h.

Values (6)
ValueLabelDescription
0 (0x0)EVENTLOG_SUCCESSSuccessful event
1 (0x1)EVENTLOG_ERROR_TPYEError event
2 (0x2)EVENTLOG_WARNING_TYPEWarning event
4 (0x4)EVENTLOG_INFORMATION_TYPEInformation event
8 (0x8)EVENTLOG_AUDIT_SUCCESSSuccess audit type
16 (0x10)EVENTLOG_AUDIT_FAILUREFailure audit type
Code
# Value of EventType for each instance
$cimParameters = @{
    ClassName = 'NTEventLogEventConsumer'
    Namespace = 'root/subscription'
    Property  = @('Name', 'EventType')
}
Get-CimInstance @cimParameters |
    Select-Object -Property Name, EventType
InsertionStringTemplatesstring[]read

Array of standard string templates that is used as the insertion string for an event log record.

Code
# Value of InsertionStringTemplates for each instance
# InsertionStringTemplates is an array: -ExpandProperty returns its items one by one
$cimParameters = @{
    ClassName = 'NTEventLogEventConsumer'
    Namespace = 'root/subscription'
    Property  = 'InsertionStringTemplates'
}
Get-CimInstance @cimParameters |
    Select-Object -ExpandProperty InsertionStringTemplates
MachineNamestringread

Name of the computer to which Windows Management Instrumentation (WMI) sends events.

Code
# Value of MachineName for each instance
$cimParameters = @{
    ClassName = 'NTEventLogEventConsumer'
    Namespace = 'root/subscription'
    Property  = @('Name', 'MachineName')
}
Get-CimInstance @cimParameters |
    Select-Object -Property Name, MachineName
MaximumQueueSizeuint32read

Maximum queue for a specific consumer, in bytes.

Code
# Value of MaximumQueueSize for each instance
$cimParameters = @{
    ClassName = 'NTEventLogEventConsumer'
    Namespace = 'root/subscription'
    Property  = @('Name', 'MaximumQueueSize')
}
Get-CimInstance @cimParameters |
    Select-Object -Property Name, MaximumQueueSize
Name keystringread

Unique name of a consumer.

Code
# Value of Name for each instance
$cimParameters = @{
    ClassName = 'NTEventLogEventConsumer'
    Namespace = 'root/subscription'
    Property  = 'Name'
}
Get-CimInstance @cimParameters |
    Select-Object -Property Name
NameOfRawDataPropertystringread

Name of the event property that contains data to be passed to the ReportEvent function *lpRawData* parameter.

Code
# Value of NameOfRawDataProperty for each instance
$cimParameters = @{
    ClassName = 'NTEventLogEventConsumer'
    Namespace = 'root/subscription'
    Property  = @('Name', 'NameOfRawDataProperty')
}
Get-CimInstance @cimParameters |
    Select-Object -Property Name, NameOfRawDataProperty
NameOfUserSidPropertystringread

Name of the event property that contains a security identifier (SID) to be passed to the ReportEvent function *lpUserSid* parameter. The property must be either an array of bytes (uint8) or a string. If it is an array of bytes, it is assumed to be a SID. If it is a string, it is a string SID that is converted into a SID.

Code
# Value of NameOfUserSidProperty for each instance
$cimParameters = @{
    ClassName = 'NTEventLogEventConsumer'
    Namespace = 'root/subscription'
    Property  = @('Name', 'NameOfUserSidProperty')
}
Get-CimInstance @cimParameters |
    Select-Object -Property Name, NameOfUserSidProperty
NumberOfInsertionStringsuint32read

Number of elements in the InsertionStringTemplates array.

Code
# Value of NumberOfInsertionStrings for each instance
$cimParameters = @{
    ClassName = 'NTEventLogEventConsumer'
    Namespace = 'root/subscription'
    Property  = @('Name', 'NumberOfInsertionStrings')
}
Get-CimInstance @cimParameters |
    Select-Object -Property Name, NumberOfInsertionStrings
SourceNamestringread

Source name where a message is located. The customer is assumed to have registered a DLL with the necessary messages.

Note: The value of this parameter must not include a colon (:) character.

Code
# Value of SourceName for each instance
$cimParameters = @{
    ClassName = 'NTEventLogEventConsumer'
    Namespace = 'root/subscription'
    Property  = @('Name', 'SourceName')
}
Get-CimInstance @cimParameters |
    Select-Object -Property Name, SourceName
UNCServerNamestringread

Name of the computer on which to log an event, or NULL if the event is to be logged on a local server.

Authenticated users cannot, by default, log events to the Application log on a remote computer. As a result, using this property to specify a remote computer will not work. To learn how to change event log security, consult this KB article.

Code
# Value of UNCServerName for each instance
$cimParameters = @{
    ClassName = 'NTEventLogEventConsumer'
    Namespace = 'root/subscription'
    Property  = @('Name', 'UNCServerName')
}
Get-CimInstance @cimParameters |
    Select-Object -Property Name, UNCServerName

Remarks

The NTEventLogEventConsumer class is derived from the __EventConsumer abstract class.

Inheritance

Superclass chain

  1. __SystemClass
  2. __IndicationRelated
  3. __EventConsumer
  4. NTEventLogEventConsumer

Known subclasses

No known subclass.

Requirements

Namespace
root/subscription
Minimum client
Windows Vista
Minimum server
Windows Server 2008
MOF file
Wbemcons.mof
DLL
Wbemcons.dll
Class qualifiers

AMENDMENT

Microsoft source

Source: Microsoft Learn

Descriptions, properties and methods come from the Microsoft documentation (MicrosoftDocs/win32 repository), published under the CC BY 4.0 licence. Formatting and translations are specific to this site; the PowerShell examples are written for it.