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


The New-PublishProfile command generates a standard publish profile xml file that can be used by the DacFx (this and everything else) to control the deployment of your dacpac.
This generates a standard template XML which is enough to deploy a dacpac but it is highly recommended that you add additional options to the publish profile.
If you use Visual Studio you can open a publish.xml file and use the UI to edit the file –
To create a new file, right click on an SSDT project, choose “Publish” then “Load Profile” and load your profile or create a new one.
Once you have loaded it in Visual Studio, clicking advanced shows you the list of options available to you.
For a full list of options that you can add to the profile, google “sqlpackage.exe command line switches” or MSDN




In this example, a prompt will appear for alternative credentials, then a connection will be made to sql2017. Using that connection, the ConnectionString will be extracted and used within the Publish Profile XML file which will be created at C:\temp\sql2017-WorldWideImporters-publish.xml.

New-DbaPublishProfile -SqlInstance sql2017 -SqlCredential (Get-Credential) -Database WorldWideImporters -Path C:\temp

In this example, no connections are made, and a Publish Profile XML would be created at C:\temp\localdb-MSSQLLocalDB-WorldWideImporters-publish.xml

New-DbaPublishProfile -Database WorldWideImporters -Path C:\temp -ConnectionString “SERVER=(localdb)\MSSQLLocalDB;Integrated Security=True;Database=master”


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


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

Source Code

Want to see the source code? View New-DbaPublishProfile.ps1 on GitHub

Related commands