__InstanceOperationEvent

Instance Operation Event

Serves as a base class for all intrinsic events that relate to an instance.

On this page

Main example

List instances

# All instances of __InstanceOperationEvent, with the main properties
Get-CimInstance -ClassName __InstanceOperationEvent -Namespace 'root' |
    Select-Object -Property SECURITY_DESCRIPTOR, TargetInstance, TIME_CREATED

Examples

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  = '__InstanceOperationEvent'
        Namespace  = 'root'
    }
    Get-CimInstance @cimParameters |
        Select-Object -Property SECURITY_DESCRIPTOR, TargetInstance, TIME_CREATED
} 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 __InstanceOperationEvent -Namespace 'root'
$cimClass.CimClassProperties |
    Select-Object -Property Name, CimType, Flags

Properties

3 of 3 properties
NameTypeAccessDescription
SECURITY_DESCRIPTORuint8[]read

Descriptor used by the event provider to determine which users can receive the event. This property is inherited from __Event.

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

Instance affected by the event. For creation events, this is the newly created instance. For modification events, this is the new version of the changed instance. For deletion events, this is the deleted instance.

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

Unique value that indicates the time at which the event was generated. This is a 64-bit value that represents the number of 100-nanosecond intervals after January 1, 1601. The information is in the Coordinated Universal Times (UTC) format. This property is inherited from __Event.

For more information about using uint64 values in scripts, see Scripting in WMI.

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

Remarks

The __InstanceOperationEvent class is derived from __Event.

Instances of __InstanceOperationEvent are not created; only instances of its subclasses are created. The following classes derive from __InstanceOperationEvent:

__InstanceCreationEvent

__InstanceModificationEvent

__InstanceDeletionEvent

Overview

Just as there is a WMI class that represents each type of system resource that can be managed using WMI, there is a WMI class that represents each type of WMI event. When an event that can be monitored by WMI occurs, an instance of the corresponding WMI event class is created. A WMI event occurs when that instance is created.

There are three major types of WMI event classes, all of which are derived from the __Event WMI class: Intrinsic Events, Extrinsic Events, and Timer Events. Intrinsic Events, in turn, are represented by three distinct classes derived from the __Event class: __NamespaceOperationEvent, __InstanceOperationEvent, and __ClassOperationEvent.

Intrinsic Events

Intrinsic events are used to monitor a resource represented by a class in the CIM repository. Each resource is represented by an instance of a class. This means that monitoring a resource using WMI actually involves monitoring the instances that correspond to the resource.

Intrinsic events can also be used to monitor changes to a namespace or class in the repository. However, monitoring changes to namespaces or classes is of limited value to system administrators.

An intrinsic event is represented by an instance of a class derived from __InstanceOperationEvent, __NamespaceOperationEvent, or __ClassOperationEvent. Any changes to instances in WMI are represented by the __InstanceOperationEvent class and the classes derived from it: __InstanceCreationEvent, __InstanceModificationEvent, and __InstanceDeletionEvent.

Monitoring resources using WMI involves monitoring instances and all changes to instances are represented by __InstanceOperationEvent and the classes derived from it. This means that monitoring resources ultimately involves monitoring instances of __InstanceOperationEvent-derived classes.

You register interest in instances of one of these classes by issuing a notification query expressed in WQL. The query uses syntax similar to the following:

SELECT * FROM __InstanceOperationEventOrDerivedClass WITHIN PollingInterval WHERE TargetInstance ISA WMIClassName AND TargetInstance.WMIClassPropertyName = Value

For a longer discussion of using the WMI instance events to monitor computer activity, see How Can I Monitor for Different Types of Events With Just One Script?

Inheritance

Superclass chain

  1. __SystemClass
  2. __IndicationRelated
  3. __Event
  4. __InstanceOperationEvent

Known subclasses

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.