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


Export-DbaDacpac

Using SQLPackage, export a dacpac from an instance of SQL Server.

Note – Extract from SQL Server is notoriously flaky – for example if you have three part references to external databases it will not work.

For help with the extract action parameters and properties, refer to MSDN

Screenshots

dbatools-Export-DbaDacpac

Examples

Exports the dacpac for SharePoint_Config on sql2016 to $home\Documents\SharePoint_Config.dacpac.

Export-DbaDacpac -SqlInstance sql2016 -Database SharePoint_Config

Sets the CommandTimeout to 10 then extracts the dacpac for SharePoint_Config on sql2016 to C:\temp\SharePoint_Config.dacpac then verifies extraction.

$moreprops = “/p:VerifyExtraction=$true /p:CommandTimeOut=10”
Export-DbaDacpac -SqlInstance sql2016 -Database SharePoint_Config -Path C:\temp -ExtendedProperties $moreprops

Author

This command was created by Richie lee. You can find Richie on Twitter.

Get-Help

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

Source Code

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

Related commands