sql-server – 通过Powershell部署dacpac导致错误:“无法确定域
有没有其他人遇到类似的问题,如下所述?
我在使用Powershell部署SQL Server 2012 dacpac数据库升级时遇到问题.详情如下所示: 它是为sql server 2012构建的dacpac文件,当我以管理员身份登录时,我试图通过Powershell从命令行运行它来应用于sql server 2012数据库. 使用“4”参数调用“Deploy”的异常:“无法确定域的身份.” 编辑过的脚本(日志记录和文字更改)如下: [System.Reflection.Assembly]::LoadFrom("C:Program Files (x86)Microsoft SQL Server110DACbinMicrosoft.SqlServer.Dac.dll") | Out-Null $d = new-object Microsoft.SqlServer.Dac.DacServices ("... Connection string ...") $TargetDatabase = "databasename" $fullDacPacPath = "c:temp...databasename.dacpac" # Load dacpac from file & deploy to database named pubsnew $dp = [Microsoft.SqlServer.Dac.DacPackage]::Load($fullDacPacPath) $DeployOptions = new-object Microsoft.SqlServer.Dac.DacDeployOptions $DeployOptions.IncludeCompositeObjects = $true $DeployOptions.IgnoreFileSize = $false $DeployOptions.IgnoreFilegroupPlacement = $false $DeployOptions.IgnoreFileAndLogFilePath = $false $DeployOptions.AllowIncompatiblePlatform = $true $d.Deploy($dp,$TargetDatabase,$DeployOptions) 以下是一些支持信息: > Dac框架版本是11.1 对网络的研究可能表明它可能与达卡的大小有关.工作的那些都小于没有的那个,this link提到了一个1.3mb的数字,失败的dacpac的文件大小刚刚超过.如果有人可以确认这是问题,你还可以建议一个解决方案吗? 更新 [Reflection.Assembly]::LoadWithPartialName("System.IO.IsolatedStorage") $f = [System.IO.IsolatedStorage.IsolatedStorageFile]::GetMachineStoreForDomain(); Write-Host($f.AvailableFreeSpace); 解决方法我相信这个问题(至少在我们的例子中)实际上是当dacpac使用一个利用多个文件组的数据库时.在进行部署比较时,我的假设是它将IsolatedStorage用于不同的文件.link above很有帮助,但它不像Tim Lewis那样在博客上的最后评论那么多.我修改了他的代码以在原生PowerShell中工作.将此置于SMO程序集加载之上应解决此问题: $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))$securityIdentityField.SetValue($currentAppDomain,$replacementEvidence) (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |