Skip to content

Send SqlReport

github-actions edited this page Jul 30, 2026 · 1 revision

external help file: Databaseline-help.xml Module Name: Databaseline online version: https://dbatools.io/ schema: 2.0.0

Send-SqlReport

SYNOPSIS

Execute a SQL statement and email the results.

SYNTAX

Send-SqlReport [-Subject] <String> [-To] <String[]> [-Sql] <String> [-SqlInstance] <DbaInstanceParameter>
 [-Database] <String> [-EmptySubject <String>] [-From <String>] [-Caption <String>] [-ReportFile <String>]
 [-QueryTimeout <Int32>] [-PreContent <String>] [-PostContent <String>] [-Cc <String[]>] [-Bcc <String[]>]
 [-Priority <MailPriority>] [-UseSsl] [-SeqUrl <Uri>] [-ProgressAction <ActionPreference>] [-WhatIf] [-Confirm]
 [<CommonParameters>]

DESCRIPTION

{{ Fill in the Description }}

EXAMPLES

Example 1

PS C:\> {{ Add example code here }}

{{ Add example description here }}

PARAMETERS

-Subject

The email subject.

Type: String
Parameter Sets: (All)
Aliases:

Required: True
Position: 1
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-To

The email address(es) to send the results to.

Type: String[]
Parameter Sets: (All)
Aliases:

Required: True
Position: 2
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-Sql

The SQL statement to execute.

Type: String
Parameter Sets: (All)
Aliases:

Required: True
Position: 3
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-SqlInstance

The server to use, by name or constructed via Connect-DbaInstance.

Type: DbaInstanceParameter
Parameter Sets: (All)
Aliases: Parent, ServerInstance

Required: True
Position: 1
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-Database

The the database to connect to on the server.

Type: String
Parameter Sets: (All)
Aliases: Name

Required: True
Position: 2
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-EmptySubject

The subject line for the email when no data is returned.

Type: String
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-From

The from address to use for the email. The default is to use $PSEmailServer.

Type: String
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-Caption

The optional table caption to add.

Type: String
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-ReportFile

A UNC path to a .csv or .tsv file writable by the script and readable by the email recipient to output the data to, which will be linked in the email rather than included in the email body.

Supports a format template for the current date and time (e.g. {0:yyyyMMddHHmmss}).

Type: String
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-QueryTimeout

The timeout to use for the query, in seconds. The default is 90.

Type: Int32
Parameter Sets: (All)
Aliases: Timeout

Required: False
Position: Named
Default value: 90
Accept pipeline input: False
Accept wildcard characters: False

-PreContent

HTML content to insert into the email before the query results.

Type: String
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-PostContent

HTML content to insert into the email after the query results.

Type: String
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-Cc

The email address(es) to CC the results to.

Type: String[]
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-Bcc

The email address(es) to BCC the results to.

Type: String[]
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-Priority

The priority of the email, one of: High, Low, Normal

Type: MailPriority
Parameter Sets: (All)
Aliases:
Accepted values: Normal, Low, High

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-UseSsl

Indicates that SSL should be used when sending the message.

(See the From parameter for an alternate SSL flag.)

Type: SwitchParameter
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False

-SeqUrl

The URL of the Seq server to log to.

Type: Uri
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: $PSDefaultParameterValues['Send-SeqEvent:Server']
Accept pipeline input: False
Accept wildcard characters: False

-WhatIf

Shows what would happen if the cmdlet runs. The cmdlet is not run.

Type: SwitchParameter
Parameter Sets: (All)
Aliases: wi

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-Confirm

Prompts you for confirmation before running the cmdlet.

Type: SwitchParameter
Parameter Sets: (All)
Aliases: cf

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-ProgressAction

{{ Fill ProgressAction Description }}

Type: ActionPreference
Parameter Sets: (All)
Aliases: proga

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.

INPUTS

OUTPUTS

System.Void

NOTES

RELATED LINKS

https://dbatools.io/

Send-MailMessage

Clone this wiki locally