Export-DbaDacPackage - How to exclude multiple object types #8650
-
Hello. I am using Export-DbaDacPackage and would like to know, if possible, how to exclude multiple object types. In my case, I'd like to exclude: Logins, Users, Roles and Permissions. The syntax examples (which are excellent) for Export-DbaDacPackage does show how to use options... PS C:> $options = New-DbaDacOption -Type Dacpac -Action Export but I still can't work out how to apply these to my scenario. Here is what I imagine it might look like to exclude just Logins, but this doesn't work... PS C:> $options = New-DbaDacOption -Type Dacpac -Action Export I suspect this is something to do with ExcludeObjectTypes not being a True or False setting... @{ExcludeObjectTypes=;} ...is one area where I'm going wrong. If possible, please can someone help me out. Thanks |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Answering my own question, but it may help someone else who wants to do the same thing. I have found one way to do it. By using New-DbaDacProfile with -PublishOptions and then publishing the dacpac via Publish-DbaDacPackage Here's the relevant snippet of the code I've done... $DacPacFileName = New-DbaDacProfile -SqlInstance $SQLSource -Database $Database -Path $DacPacPath -WarningAction Stop Export-DbaDacPackage -SqlInstance $SQLSource -Database $Database | Publish-DbaDacPackage -PublishXml $DacPacFileName -Database $Database -SqlInstance $SQLDestination Thanks |
Beta Was this translation helpful? Give feedback.
Answering my own question, but it may help someone else who wants to do the same thing.
I have found one way to do it.
By using New-DbaDacProfile with -PublishOptions and then publishing the dacpac via Publish-DbaDacPackage
Here's the relevant snippet of the code I've done...
$DacPacFileName = New-DbaDacProfile -SqlInstance $SQLSource -Database $Database -Path $DacPacPath -WarningAction Stop
-PublishOptions @{ExcludeLogins=$true;ExcludeUsers=$true;IgnoreRoleMembership=$true;} | SELECT -ExpandProperty FileName
Export-DbaDacPackage -SqlInstance $SQLSource -Database $Database | Publish-DbaDacPackage -PublishXml $DacPacFileName -Database $Database -SqlInstance $SQLDestination
Thanks