< Back

New-DbaDacProfile

Mon Jan 13, 2020 12:47 pm

NAME New-DbaDacProfile



SYNOPSIS

Creates a new Publish Profile.





SYNTAX

New-DbaDacProfile [[-SqlInstance] <Sqlcollaborative.Dbatools.Parameter.DbaInstanceParameter[]>] [[-SqlCredential]

<Pscredential>] [-Database] <System.String[]> [[-Path] <String>] [[-ConnectionString] <System.String[]>]

[[-PublishOptions] <Hashtable>] [-EnableException <Switch>] [<CommonParameters>]





DESCRIPTION

The New-DbaDacProfile 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 dpeloy 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

(https://msdn.microsoft.com/en-us/librar ... .103).aspx)





PARAMETERS

-ConnectionString [<System.String[]>]

The connection string to the database you are upgrading.



Alternatively, you can provide a SqlInstance (and optionally SqlCredential) and the script will connect and

generate the connectionstring.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-Database [<System.String[]>]

The database name you are targeting



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-EnableException [<Switch>]

By default, when something goes wrong we try to catch it, interpret it and give you a friendly warning message.

This avoids overwhelming you with "sea of red" exceptions, but is inconvenient because it basically disables

advanced scripting.

Using this switch turns this "nice by default" feature off and enables you to catch exceptions with your own

try/catch.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-Path [<String>]

The directory where you would like to save the profile xml file(s).



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-PublishOptions [<Hashtable>]

Optional hashtable to set publish options. Key/value pairs in the hashtable get converted to strings of

"<key>value</key>".



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-SqlCredential [<Pscredential>]

Login to the target instance using alternative credentials. Accepts PowerShell credentials (Get-Credential).



Windows Authentication, SQL Server Authentication, Active Directory - Password, and Active Directory -

Integrated are all supported.



For MFA support, please use Connect-DbaInstance.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-SqlInstance [<Sqlcollaborative.Dbatools.Parameter.DbaInstanceParameter[]>]

The target SQL Server instance or instances. Alternatively, you can provide a ConnectionString.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



<CommonParameters>

This cmdlet supports the common parameters: Verbose, Debug,

ErrorAction, ErrorVariable, WarningAction, WarningVariable,

OutBuffer, PipelineVariable, and OutVariable. For more information, see

about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).



INPUTS



OUTPUTS



NOTES





Tags: Dacpac

Author: Richie lee (@richiebzzzt)



Website: https://dbatools.io

Copyright: (c) 2018 by dbatools, licensed under MIT

License: MIT https://opensource.org/licenses/MIT



-------------------------- EXAMPLE 1 --------------------------



PS C:\\>New-DbaDacProfile -SqlInstance sql2017 -SqlCredential ad\\sqldba -Database WorldWideImporters -Path C:\\temp



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

-------------------------- EXAMPLE 2 --------------------------



PS C:\\>New-DbaDacProfile -Database WorldWideImporters -Path C:\\temp -ConnectionString

"SERVER=(localdb)\\MSSQLLocalDB;Integrated Security=True;Database=master"



In this example, no connections are made, and a Publish Profile XML would be created at

C:\\temp\\localdb-MSSQLLocalDB-WorldWideImporters-publish.xml



RELATED LINKS

https://dbatools.io/New-DbaDacProfile