有没有其他人遇到过与下面描述的类似的问题?
我在使用 Powershell 部署 SQL Server 2012 dacpac 数据库升级时遇到问题。详细情况如下:
它是为 sql server 2012 构建的 dacpac 文件,我正在尝试通过以管理员身份登录时从命令行运行的 Powershell 将其应用于 sql server 2012 数据库。
使用“4”参数调用“部署”的异常:“无法确定域的身份。” 在 ... so.ps1:17 char:8 + $d.Deploy($dp, $TargetDatabase,$true,$DeployOptions)
编辑后的脚本(日志和文字已更改)如下:
[System.Reflection.Assembly]::LoadFrom("C:\Program Files (x86)\Microsoft SQL Server\110\DAC\bin\Microsoft.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,$true,$DeployOptions)
以下是一些支持信息:
- Dac 框架版本为 11.1
- 该脚本在命令行上运行时会引发错误:
即。Powershell -File databaseupgrade.ps1
但在Powershell集成脚本环境中运行时没有 - 其他 dacpacs 的命令行也可以使用类似的脚本。
网络研究可能表明这可能与 dacpac 的大小有关。工作的都比不工作的小,这个链接提到了一个 1.3mb 的数字,失败的 dacpac 的文件大小刚刚超过。如果有人可以确认这是问题所在,您还可以提出解决方案吗?
更新 以下脚本表现出相同的行为,即。在 PS Ide 中工作而不是从命令行。
[Reflection.Assembly]::LoadWithPartialName("System.IO.IsolatedStorage")
$f = [System.IO.IsolatedStorage.IsolatedStorageFile]::GetMachineStoreForDomain();
Write-Host($f.AvailableFreeSpace);