__EventFilter

Event Filter
rootkey : Name

The registration of a permanent event consumer requires an instance of the __EventFilter system class.

On this page

Main example

List instances

# All instances of __EventFilter, with the main properties
Get-CimInstance -ClassName __EventFilter -Namespace 'root' |
    Select-Object -Property Name, EventAccess, EventNamespace, Query

Examples

Filter with WQL

# WQL filter evaluated by the provider: names starting with "a" (the WQL wildcard is %)
$cimParameters = @{
    ClassName = '__EventFilter'
    Namespace = 'root'
    Filter    = "Name LIKE 'a%'"
}
Get-CimInstance @cimParameters |
    Select-Object -Property Name, EventAccess, EventNamespace, Query

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  = '__EventFilter'
        Namespace  = 'root'
    }
    Get-CimInstance @cimParameters |
        Select-Object -Property Name, EventAccess, EventNamespace, Query
} 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 __EventFilter -Namespace 'root'
$cimClass.CimClassProperties |
    Select-Object -Property Name, CimType, Flags

Properties

6 of 6 properties
NameTypeAccessDescription
CreatorSIDuint8[]read/write

Security identifier (SID) that uniquely identifies the user who creates this filter. Windows Management Instrumentation (WMI) stores the SID of the user that creates an instance of __EventFilter 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 = '__EventFilter'
    Namespace = 'root'
    Property  = 'CreatorSID'
}
Get-CimInstance @cimParameters |
    Select-Object -ExpandProperty CreatorSID

Warning. Changes the system: check with -WhatIf first. An elevated console is often required.

# Warning: changes CreatorSID on the instance. -WhatIf shows the operation without running it.
# Target instance
$instanceParameters = @{
    ClassName = '__EventFilter'
    Namespace = 'root'
    Filter    = "Name = 'Example'"
}
$instance = Get-CimInstance @instanceParameters
$setParameters = @{
    InputObject = $instance
    Property    = @{ CreatorSID = @(0) }
    WhatIf      = $true  # Remove this line to actually apply the change
}
Set-CimInstance @setParameters
EventAccessstringread/write

Security descriptor (SD) in Security Descriptor Definition Language (SDDL) that controls access for events delivered to the filter. Use this property to specify that only events in the security context of specific accounts can be delivered to this filter. For example, a permanent event consumer may clear the security logs only when a specific event is generated by a specific user. To specify who can publish events to this filter, use the WBEM_RIGHT_PUBLISH mask in the Access Control Entry (ACE) for the SECURITY_DESCRIPTOR property. For more information, see Security Descriptor Definition Language. For more information about constants used to set this security descriptor, see WMI Security Constants. For more information and examples, see Receiving Events Securely.

You can configure an event access security descriptor to allow an event to be delivered only when the local system account generates the event. For more information about creating security descriptor and authorizing access, see Access Control.

Example: The following SDDL string allows only administrators to provide events to the filter. The right required to provide events is WBEM_RIGHT_PUBLISH (x80).

```VB

O:BAG:BAD:(A;;0x80;;;BA)

```

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

Warning. Changes the system: check with -WhatIf first. An elevated console is often required.

# Warning: changes EventAccess on the instance. -WhatIf shows the operation without running it.
# Target instance
$instanceParameters = @{
    ClassName = '__EventFilter'
    Namespace = 'root'
    Filter    = "Name = 'Example'"
}
$instance = Get-CimInstance @instanceParameters
$setParameters = @{
    InputObject = $instance
    Property    = @{ EventAccess = 'Example' }
    WhatIf      = $true  # Remove this line to actually apply the change
}
Set-CimInstance @setParameters
EventNamespacestringread/write

Namespace of the event instance used for cross-namespace subscriptions.

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

Warning. Changes the system: check with -WhatIf first. An elevated console is often required.

# Warning: changes EventNamespace on the instance. -WhatIf shows the operation without running it.
# Target instance
$instanceParameters = @{
    ClassName = '__EventFilter'
    Namespace = 'root'
    Filter    = "Name = 'Example'"
}
$instance = Get-CimInstance @instanceParameters
$setParameters = @{
    InputObject = $instance
    Property    = @{ EventNamespace = 'Example' }
    WhatIf      = $true  # Remove this line to actually apply the change
}
Set-CimInstance @setParameters
Name keystringread/write

Unique identifier of an event filter. Because an event filter is only used internally by WMI, it is recommended that you set this property to a globally unique identifier (GUID) converted to a string. However, consumers can use any private scheme for a filter name as long as there is not a conflict with other filters.

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

Warning. Changes the system: check with -WhatIf first. An elevated console is often required.

# Warning: changes Name on the instance. -WhatIf shows the operation without running it.
# Target instance
$instanceParameters = @{
    ClassName = '__EventFilter'
    Namespace = 'root'
    Filter    = "Name = 'Example'"
}
$instance = Get-CimInstance @instanceParameters
$setParameters = @{
    InputObject = $instance
    Property    = @{ Name = 'Example' }
    WhatIf      = $true  # Remove this line to actually apply the change
}
Set-CimInstance @setParameters
Querystringread/write

Windows Management Instrumentation Query Language (WQL) event query that specifies the set of events for consumer notification, and the specific conditions for notification.

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

Warning. Changes the system: check with -WhatIf first. An elevated console is often required.

# Warning: changes Query on the instance. -WhatIf shows the operation without running it.
# Target instance
$instanceParameters = @{
    ClassName = '__EventFilter'
    Namespace = 'root'
    Filter    = "Name = 'Example'"
}
$instance = Get-CimInstance @instanceParameters
$setParameters = @{
    InputObject = $instance
    Property    = @{ Query = 'Example' }
    WhatIf      = $true  # Remove this line to actually apply the change
}
Set-CimInstance @setParameters
QueryLanguagestringread/write

Language used for the query. Because WMI currently supports only WMI Query Language (WQL) as a query language, this property must be set to "WQL".

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

Warning. Changes the system: check with -WhatIf first. An elevated console is often required.

# Warning: changes QueryLanguage on the instance. -WhatIf shows the operation without running it.
# Target instance
$instanceParameters = @{
    ClassName = '__EventFilter'
    Namespace = 'root'
    Filter    = "Name = 'Example'"
}
$instance = Get-CimInstance @instanceParameters
$setParameters = @{
    InputObject = $instance
    Property    = @{ QueryLanguage = 'Example' }
    WhatIf      = $true  # Remove this line to actually apply the change
}
Set-CimInstance @setParameters

Remarks

The __EventFilter class is derived from __IndicationRelated.

Inheritance

Superclass chain

  1. __SystemClass
  2. __IndicationRelated
  3. __EventFilter

Known subclasses

No known subclass.

Requirements

Namespace
root
Minimum client
Windows Vista
Minimum server
Windows Server 2008
DLL
All

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.