commands

^

New-DbaXESmartEmail

Author Chrissy LeMaire (@cl) , SmartTarget by Gianluca Sartori (@spaghettidba)
Availability Windows, Linux, macOS

 

Want to see the source code for this command? Check out New-DbaXESmartEmail on GitHub.
Want to see the Bill Of Health for this command? Check out New-DbaXESmartEmail.

Synopsis

This response type can be used to send an email each time an event is captured.

Description

This response type can be used to send an email each time an event is captured.

Syntax

New-DbaXESmartEmail
    [-SmtpServer] <String>
    [-Sender] <String>
    [-To] <String[]>
    [[-Cc] <String[]>]
    [[-Bcc] <String[]>]
    [[-Credential] <PSCredential>]
    [-Subject] <String>
    [-Body] <String>
    [[-Attachment] <String>]
    [[-AttachmentFileName] <String>]
    [[-PlainText] <String>]
    [[-Event] <String[]>]
    [[-Filter] <String>]
    [-EnableException]
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]

 

Examples

 

Example: 1
PS C:\> $params = @{
>> SmtpServer = "smtp.ad.local"
>> To = "[email protected]"
>> Sender = "[email protected]"
>> Subject = "Query executed"
>> Body = "Query executed at {collection_time}"
>> Attachment = "batch_text"
>> AttachmentFileName = "query.sql"
>> }
>>
PS C:\> $emailresponse = New-DbaXESmartEmail @params
PS C:\> Start-DbaXESmartTarget -SqlInstance sql2017 -Session querytracker -Responder $emailresponse

Sends an email each time a querytracker event is captured.

Required Parameters

-SmtpServer

Address of the SMTP server for outgoing mail.

Alias
Required True
Pipeline false
Default Value
-Sender

Sender's email address.

Alias
Required True
Pipeline false
Default Value
-To

Address of the To recipient(s).

Alias
Required True
Pipeline false
Default Value
-Subject

Subject of the mail message. Accepts placeholders in the text.
Placeholders are in the form , where PropertyName is one of the fields or actions available in the Event object.
For instance, a valid Subject in a configuration file looks like this: "An event of name occurred at "

Alias
Required True
Pipeline false
Default Value
-Body

Body of the mail message. The body can be static text or any property taken from the underlying event. See Subject for a description of how placeholders work.

Alias
Required True
Pipeline false
Default Value

Optional Parameters

-Cc

Address of the Cc recipient(s).

Alias
Required False
Pipeline false
Default Value
-Bcc

Address of the Bcc recipient(s).

Alias
Required False
Pipeline false
Default Value
-Credential

Credential object containing username and password used to authenticate on the SMTP server. When blank, no authentication is performed.

Alias
Required False
Pipeline false
Default Value
-Attachment

Data to attach to the email message. At this time, it can be any of the fields/actions of the underlying event. The data from the field/action is attached to the message as an ASCII stream. A single
attachment is supported.

Alias
Required False
Pipeline false
Default Value
-AttachmentFileName

File name to assign to the attachment.

Alias
Required False
Pipeline false
Default Value
-PlainText

If this switch is enabled, the email will be sent in plain text. By default, HTML formatting is used.

Alias
Required False
Pipeline false
Default Value
-Event

Each Response can be limited to processing specific events, while ignoring all the other ones. When this attribute is omitted, all events are processed.

Alias
Required False
Pipeline false
Default Value
-Filter

You can specify a filter expression by using this attribute. The filter expression is in the same form that you would use in a SQL query. For example, a valid example looks like this: duration >
10000 AND cpu_time > 10000

Alias
Required False
Pipeline false
Default Value
-EnableException

By default, when something goes wrong we try to catch it, interpret it and give you a friendly warning message.
This avoids overwhelming you with "sea of red" exceptions, but is inconvenient because it basically disables advanced scripting.
Using this switch turns this "nice by default" feature off and enables you to catch exceptions with your own try/catch.

Alias
Required False
Pipeline false
Default Value False
-WhatIf

If this switch is enabled, no actions are performed but informational messages will be displayed that explain what would happen if the command were to run.

Alias wi
Required False
Pipeline false
Default Value
-Confirm

If this switch is enabled, you will be prompted for confirmation before executing any operations that change state.

Alias cf
Required False
Pipeline false
Default Value