commands

^

New-DbaDacOption

Author Kirill Kravtsov (@nvarscar), nvarscar.wordpress.com
Availability Windows, Linux, macOS

 

Synopsis

Creates a new Microsoft.SqlServer.Dac.DacExtractOptions/DacExportOptions object depending on the chosen Type

Description

Creates a new Microsoft.SqlServer.Dac.DacExtractOptions/DacExportOptions object that can be used during DacPackage extract. Basically saves you the time from remembering the SMO assembly name ;)

See: https://msdn.microsoft.com/en-us/library/microsoft.sqlserver.dac.dacexportoptions.aspx https://msdn.microsoft.com/en-us/library/microsoft.sqlserver.dac.dacextractoptions.aspx for more information

Syntax

New-DbaDacOption
    [[-Type] <String>]
    [-Action] <String>
    [[-PublishXml] <String>]
    [-EnableException]
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]

 

Examples

 

Example: 1
PS C:\> $options = New-DbaDacOption -Type Dacpac -Action Export
PS C:\> $options.ExtractAllTableData = $true
PS C:\> $options.CommandTimeout = 0
PS C:\> Export-DbaDacPackage -SqlInstance sql2016 -Database DB1 -Options $options

Uses DacOption object to set the CommandTimeout to 0 then extracts the dacpac for SharePoint_Config on sql2016 to C:\temp\SharePoint_Config.dacpac including all table data.

Example: 2
PS C:\> $options = New-DbaDacOption -Type Dacpac -Action Publish
PS C:\> $options.DeployOptions.DropObjectsNotInSource = $true
PS C:\> Publish-DbaDacPackage -SqlInstance sql2016 -Database DB1 -Options $options -Path c:\temp\db.dacpac

Uses DacOption object to set Deployment Options and publish the db.dacpac dacpac file as DB1 on sql2016

Required Parameters

-Action

Choosing an intended action: Publish or Export.

Alias
Required True
Pipeline false
Default Value
Accepted Values Publish,Export

Optional Parameters

-Type

Selecting the type of the export: Dacpac (default) or Bacpac.

Alias
Required False
Pipeline false
Default Value Dacpac
Accepted Values Dacpac,Bacpac
-PublishXml

Specifies the publish profile which will include options and sqlCmdVariables.

Alias
Required False
Pipeline false
Default Value
-EnableException

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.

Alias
Required False
Pipeline false
Default Value False
-WhatIf

If this switch is enabled, no actions are performed but informational messages will be displayed that explain what would happen if the command were to run.

Alias wi
Required False
Pipeline false
Default Value
-Confirm

If this switch is enabled, you will be prompted for confirmation before executing any operations that change state.

Alias cf
Required False
Pipeline false
Default Value

 

Want to see the source code for this command? Check out New-DbaDacOption on GitHub.
Want to see the Bill Of Health for this command? Check out New-DbaDacOption.