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 history of mail sent from a SQL instance.




Returns the entire dbmail history on sql01\sharepoint.

Get-DbaDbMailHistory -SqlInstance sql01\sharepoint

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

Get-DbaDbMailHistory -SqlInstance sql01\sharepoint | Select *

Returns the all dbmail history for “sql2014″,”sql2016” and “sqlcluster\sharepoint”.

$servers = “sql2014″,”sql2016”, “sqlcluster\sharepoint”
$servers | Get-DbaDbMailHistory


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


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

Source Code

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

Related commands