dbatools is a free PowerShell module with over 200 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


Export-DbaExecutionPlan

Exports execution plans to disk. Can pipe from Get-DbaExecutionPlan 😀

Thanks to Louis Davidson and Tim Ford for the query and Grant Fritchey for the idea.

Screenshots

Examples

To export all execution plans for sqlserver2014a to the directory C:\temp\sqlplans

Export-DbaExecutionPlan -SqlInstance sqlserver2014a -Path C:\temp\sqlplans

To exports all execution plans for databases db1 and db2 on sqlserve2014a since July 1, 2016 at 10:47 AM to the directory C:\temp\sqlplans

Export-DbaExecutionPlan -SqlInstance sqlserver2014a -Databases db1, db2 -SinceLastExecution ‘7/1/2016 10:47:00’ -Path C:\temp\sqlplans

Get-Help

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

Source Code

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

Related commands