Deploying a dacpac via Powershell caused error: “Unable to determine the identity of domain”


Has anyone else met a similar problem to the one described below?

I am having a problem deploying a SQL server 2012 dacpac database upgrade with Powershell. The details are as follows:

Its a dacpac file built for sql server 2012 and I’m trying to apply it to a sql server 2012 database via Powershell run from the command line when logged in as administrator.

Exception calling “Deploy” with “4” argument(s): “Unable to determine the identity of domain.”
At … so.ps1:17 char:8
+ $d.Deploy($dp, $TargetDatabase,$true,$DeployOptions)

The redacted script (logging and literals changed) is as follows:

Here is some supporting information:

  1. Dac framework version is 11.1
  2. The script throws the error when run on the command line:
    ie. Powershell -File databaseupgrade.ps1
    but not when run in the Powershell integrated script environment
  3. Similar scripts work from the command line for other dacpacs.

Research on the web might suggest that it might be something to do with the size of dacpac. The ones that work are all smaller than the one that does not and this link mentions a figure of 1.3mb which the file size of the failing dacpac just exceeds. If anyone can confirm that this is the problem can you also suggest a solution?

The following script exhibits the same behavior ie. works in PS Ide not from command line.


I believe this issue here (at least in our case) is actually when the dacpac is working with a database that utilizes multiple filegroups. When doing the comparison for deployment my hypothesis is that it’s utilizing the IsolatedStorage for the different files.

The link above was helpful, but it was not the entry as much as the last comment on that blog by Tim Lewis. I modified his code to work in native powershell. Putting this above the SMO assembly load should fix this issue:

$replacementEvidence = New-Object System.Security.Policy.Evidence
$replacementEvidence.AddHost((New-Object System.Security.Policy.Zone ([Security.SecurityZone]::MyComputer)))
$currentAppDomain = [System.Threading.Thread]::GetDomain()
$securityIdentityField = $currentAppDomain.GetType().GetField("_SecurityIdentity", ([System.Reflection.BindingFlags]::Instance -bOr [System.Reflection.BindingFlags]::NonPublic))


Deploying a dacpac via Powershell caused error: “Unable to determine the identity of domain” by licensed under CC BY-SA | With most appropriate answer!

Leave a Reply