How to have multiple exclusions using /:p ExcludeObjectTypes

52 Views Asked by At

Keeping it simple, this is the piece of code Im having an issue with

.\SqlPackage.exe /Action:Script 
/SourceFile:"$outputDirectory\$outputDacpacFile" 
/TargetServerName:$targetServer /TargetDatabaseName:$targetDatabase 
/TargetUser:$targetUser /TargetPassword:$targetPassword 
/OutputPath:"$outputDirectory\$outputTSQLfile" 
/p:ExcludeObjectTypes=DatabaseRoles;Users

The ExcludeObjectTypes seems to only process whatever appears first after the =. So if I put =Users, it will get rid of the users from the Tsql script and if I enter =DatabaseRoles then it will get rid of the roles. I cant seem to get them to work together. I've tried adding another /p:ExcludeObjectTypes (one for DatabaseRoles and one for Users) but I get an error mentioning that ive entered a duplicate.

Any ideas?

1

There are 1 best solutions below

0
On

Semicolon ; may be treated as a command terminator symbol in CMD or Powershell. You can pass multiple object types by setting /p:ExcludeObjectType (not plural) multiple times in command line e.g:

... /p:ExcludeObjectType=DatabaseRoles /p:ExcludeObjectType=Users ...

or try with quotes around object types list.