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, EventTypeExamples
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, EventTypeThe 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, FlagsProperties
| Name | Type | Access | Description | |||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Category# | uint16 | read | Event category. This is source-specific information and can have any value. Code | |||||||||||||||||||||
| CreatorSID# | uint8[] | 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 | |||||||||||||||||||||
| EventID# | uint32 | read | Event message in the message DLL. This property cannot be NULL. Code | |||||||||||||||||||||
| EventType# | uint32 | read | Type of event. This parameter can have one of the values listed in the following list, which are defined in Winnt.h. Values (6)
Code | |||||||||||||||||||||
| InsertionStringTemplates# | string[] | read | Array of standard string templates that is used as the insertion string for an event log record. Code | |||||||||||||||||||||
| MachineName# | string | read | Name of the computer to which Windows Management Instrumentation (WMI) sends events. Code | |||||||||||||||||||||
| MaximumQueueSize# | uint32 | read | Maximum queue for a specific consumer, in bytes. Code | |||||||||||||||||||||
| Name# key | string | read | Unique name of a consumer. Code | |||||||||||||||||||||
| NameOfRawDataProperty# | string | read | Name of the event property that contains data to be passed to the ReportEvent function *lpRawData* parameter. Code | |||||||||||||||||||||
| NameOfUserSidProperty# | string | read | 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 | |||||||||||||||||||||
| NumberOfInsertionStrings# | uint32 | read | Number of elements in the InsertionStringTemplates array. Code | |||||||||||||||||||||
| SourceName# | string | read | 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 | |||||||||||||||||||||
| UNCServerName# | string | read | 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 |
Remarks
The NTEventLogEventConsumer class is derived from the __EventConsumer abstract class.
Inheritance
Superclass chain
- __SystemClass
- __IndicationRelated
- __EventConsumer
- 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
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.