Main example
List instances
# All instances of SMTPEventConsumer, with the main properties
Get-CimInstance -ClassName SMTPEventConsumer -Namespace 'root/subscription' |
Select-Object -Property Name, BccLine, CcLine, FromLineExamples
Filter with WQL
# WQL filter evaluated by the provider: names starting with "a" (the WQL wildcard is %)
$cimParameters = @{
ClassName = 'SMTPEventConsumer'
Namespace = 'root/subscription'
Filter = "Name LIKE 'a%'"
}
Get-CimInstance @cimParameters |
Select-Object -Property Name, BccLine, CcLine, FromLineThe 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 = 'SMTPEventConsumer'
Namespace = 'root/subscription'
}
Get-CimInstance @cimParameters |
Select-Object -Property Name, BccLine, CcLine, FromLine
} 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 SMTPEventConsumer -Namespace 'root/subscription'
$cimClass.CimClassProperties |
Select-Object -Property Name, CimType, FlagsProperties
| Name | Type | Access | Description |
|---|---|---|---|
| BccLine# | string | read | A list of addresses, separated by a comma or semicolon, in the format of a standard string template to which the message is sent as a blind carbon copy. For more information, see the Remarks section of this topic. Code |
| CcLine# | string | read | A list of addresses, separated by a comma or semicolon, in the format of a standard string template to which the message is sent as a carbon copy. For more information, see the Remarks section of this topic. 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 |
| FromLine# | string | read | From line of an email message in the format of a standard string template. If NULL, a From line is constructed in the form of "WinMgmt@*MachineName*". Code |
| HeaderFields# | string[] | read | Array of header fields that are inserted into an email message without interpretation. 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 |
| Message# | string | read | Standard string template that contains the body of an email message. Code |
| Name# key | string | read | Unique identifier for the event consumer. Code |
| ReplyToLine# | string | read | Reply-to line of an email message in the format of a standard string template. If NULL, no Reply-to line is used. Code |
| SMTPServer# | string | read | Name of the SMTP server through which an email is sent. Permissible names are an IP address, or a DNS or NetBIOS name. This property cannot be NULL. Code |
| Subject# | string | read | Standard string template that contains the subject of an email message. Code |
| ToLine# | string | read | A list of addresses, separated by a comma or semicolon, in the format of a standard string template that identifies where the message is to be sent. For more information, see the Remarks section of this topic. Code |
Remarks
The SMTPEventConsumer class is derived from the __EventConsumer abstract class.
Some of the ToLine, CcLine, or BccLine properties can be NULL, but they cannot all be NULL.
Receiving an error return code from the SMTP service is considered a failure.
Inheritance
Superclass chain
- __SystemClass
- __IndicationRelated
- __EventConsumer
- SMTPEventConsumer
Known subclasses
No known subclass.
Requirements
- Namespace
- root/subscription
- Minimum client
- Windows Vista
- Minimum server
- Windows Server 2008
- MOF file
- Smtpcons.mof
- DLL
- Smtpcons.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.