Main example
List instances
# All instances of ActiveScriptEventConsumer, with the main properties
Get-CimInstance -ClassName ActiveScriptEventConsumer -Namespace 'root/subscription' |
Select-Object -Property Name, KillTimeout, MachineName, MaximumQueueSizeExamples
Filter with WQL
# WQL filter evaluated by the provider: names starting with "a" (the WQL wildcard is %)
$cimParameters = @{
ClassName = 'ActiveScriptEventConsumer'
Namespace = 'root/subscription'
Filter = "Name LIKE 'a%'"
}
Get-CimInstance @cimParameters |
Select-Object -Property Name, KillTimeout, MachineName, MaximumQueueSizeThe 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 = 'ActiveScriptEventConsumer'
Namespace = 'root/subscription'
}
Get-CimInstance @cimParameters |
Select-Object -Property Name, KillTimeout, MachineName, MaximumQueueSize
} 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 ActiveScriptEventConsumer -Namespace 'root/subscription'
$cimClass.CimClassProperties |
Select-Object -Property Name, CimType, FlagsProperties
| Name | Type | Access | Description |
|---|---|---|---|
| CreatorSID# | uint8[] | read | Array that represents the security identifier (SID), which uniquely identifies the creator of the Active Script Event consumer. This property is inherited from __EventConsumer. Code |
| KillTimeout# | uint32 | read | Number, in seconds, that the script is allowed to run. If 0 (zero), which is the default, the script is not terminated. Code |
| MachineName# | string | read | Name of the computer to which WMI sends events. By convention of Microsoft standard consumers, the script consumer cannot be run remotely. Third-party consumers can also use this property. This property is inherited from __EventConsumer. Code |
| MaximumQueueSize# | uint32 | read | Maximum queue, in bytes, for the Active Script Event consumer. This property is inherited from __EventConsumer. Code |
| Name# key | string | read/write | Unique identifier for the event consumer. If you rename the consumer, the result is two equal consumers that have different names. CodeWarning. Changes the system: check with -WhatIf first. An elevated console is often required. |
| ScriptFileName# | string | read | Name of the file from which the script text is read, intended as an alternative to specifying the text of the script in the ScriptText property. This property must be NULL if the ScriptText property is not NULL. Note: When you specify the ScriptFileName, it is important to secure the executable that you are launching. If the executable is not in a secure location or secured with a strong access control list (ACL), anyone can replace the executable with a different one. For more information about ACLs, see Creating a Security Descriptor (SD) for a New Object in C++. Code |
| ScriptingEngine# | string | read | Name of the scripting engine to use, for example, "VBScript". This property cannot be NULL. Code |
| ScriptText# | string | read | Text of the script that is expressed in a language known to the scripting engine. This property must be NULL if the ScriptFileName property is not NULL. Code |
Remarks
This class is derived from the __EventConsumer abstract class. It is located in the root\subscription namespace.
When the text of a script is specified in the event consumer instance, the script has access to the event instance in the script environment variable TargetEvent.
The scripts run in the LocalSystem security context. As a security measure, only a local system administrator or a domain administrator can configure the scripting consumer. Access rights are not checked until run time. After the consumer is configured, any user can trigger the event that causes the script to .
Failure to load the scripting engine or parse and validate the script is considered a failure. Error return codes from the script and terminating the script by using a time-out are also considered failures.
Either ScriptText or ScriptFileName must be not NULL. If both properties are NULL or not NULL, an error is generated.
When WMI is run as a service, scripts run by ActiveScriptEventConsumer do not generate screen output. Scripts that use MsgBox do run, but they do not display information on the screen. Running the WMI service as an executable file is not supported, but WMI allows scripts that use the MsgBox function to display output or accept user input. None of the methods provided by the WScript) object can be used because ActiveScriptEventConsumer does not use Windows Script Host (WSH).
Inheritance
Superclass chain
- __SystemClass
- __IndicationRelated
- __EventConsumer
- ActiveScriptEventConsumer
Known subclasses
No known subclass.
Requirements
- Namespace
- root/subscription
- Minimum client
- Windows Vista
- Minimum server
- Windows Server 2008
- MOF file
- Scrcons.mof
- DLL
- Scrcons.exe
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.