< Back

New-DbaDacOption

Mon Jan 13, 2020 12:47 pm

NAME New-DbaDacOption



SYNOPSIS

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





SYNTAX

New-DbaDacOption [[-Type] <String>] [-Action] <String> [[-PublishXml] <String>] [-EnableException <Switch>]

[<CommonParameters>]





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/librar ... tions.aspx



https://msdn.microsoft.com/en-us/librar ... tions.aspx



for more information





PARAMETERS

-Action [<String>]

Choosing an intended action: Publish or Export.



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



-PublishXml [<String>]

Specifies the publish profile which will include options and sqlCmdVariables.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-Type [<String>]

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



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: Migration, Database, Dacpac

Author: Kirill Kravtsov (@nvarscar), nvarscar.wordpress.com



Website: https://dbatools.io

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

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



-------------------------- 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



RELATED LINKS

https://dbatools.io/New-DbaDacOption