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


Get-DbaExecutionPlan

Gets execution plans and metadata – useful for piping to Export-DbaExecutionPlan.

Screenshots

Examples

To return all execution plans on sqlserver2014a

Get-DbaExecutionPlan -SqlInstance sqlserver2014a

To return all execution plans for databases db1 and db2 on sqlserve2014a since July 1, 2016 at 10:47 AM, and make the output pretty

Get-DbaExecutionPlan -SqlInstance sqlserver2014a -Databases db1, db2 -SinceLastExecution ‘7/1/2016 10:47:00’ | Format-Table

To return of detailed information for execution plans on all databases except db1 on sqlserver2014a and sql2016

Get-DbaExecutionPlan -SqlInstance sqlserver2014a, sql2016 -Force -Exclude db1

To return From and To file information to output, returns information only for AdventureWorks2014 and pubs

Get-DbaExecutionPlan -SqlInstance sql2014 -Databases AdventureWorks2014, pubs -Force

Get-Help

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

Source Code

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

Related commands