dbatools is a free PowerShell module with over 300 SQL Server administration, best practice and migration commands included.

Please note that documentation and command names may be out of date while we work furiously towards 1.0


Gets the DBMail log from a SQL instance.




Returns the entire dbmail log on sql01\sharepoint.

Get-DbaDbMailLog -SqlInstance sql01\sharepoint

Returns the entire dbmail log on sql01\sharepoint then return a bunch more columns.

Get-DbaDbMailLog -SqlInstance sql01\sharepoint | Select *

Returns only the Error and Information dbmail log for “sql2014″,”sql2016” and “sqlcluster\sharepoint”.

$servers = “sql2014″,”sql2016”, “sqlcluster\sharepoint”
$servers | Get-DbaDbMailLog -Type Error, Information


This command was created by Chrissy LeMaire. You can find Chrissy on Twitter.


From PowerShell, execute Get-Help Get-DbaDbMailLog -Detailed for more information on this function.

Source Code

Want to see the source code? View Get-DbaDbMailLog.ps1 on GitHub

Related commands