powershell - 使用 Powershell 部署 SSIS - 缺少 DMF
问题描述
我正在尝试编写一个 PowerShell 脚本来部署和 SSIS 项目。这是我的代码。
# Variables
$SSISNamespace = "Microsoft.SqlServer.Management.IntegrationServices"
$TargetServerName = "FBISQL003DV"
$TargetFolderName = "DEV"
$ProjectFilePath = "C:\Users\Brian.Ciampa\source\Workspaces\TFICM2\TFCIM\DEV\CIM\SSIS\BC_TEST\bin\Development\BC_TEST.ispac"
$ProjectName = "BC_TEST"
# Load the IntegrationServices assembly. This is located at C:\windows\assembly.
$loadStatus = [System.Reflection.Assembly]::Load("Microsoft.SQLServer.Management.IntegrationServices, "+
"Version=13.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91, processorArchitecture=MSIL")
# Create a connection to the server
$sqlConnectionString = `
"Data Source=" + $TargetServerName + ";Initial Catalog=master;Integrated Security=SSPI;"
$sqlConnection = New-Object System.Data.SqlClient.SqlConnection $sqlConnectionString
# Create the Integration Services object
$integrationServices = New-Object $SSISNamespace".IntegrationServices" $sqlConnection
# Get the Integration Services catalog
$catalog = $integrationServices.Catalogs["SSISDB"]
# Create the target folder
$folder = New-Object $SSISNamespace".CatalogFolder" ($catalog, $TargetFolderName,
"Folder description")
$folder.Create()
Write-Host "Deploying " $ProjectName " project ..."
# Read the project file and deploy it
[byte[]] $projectFile = [System.IO.File]::ReadAllBytes($ProjectFilePath)
$folder.DeployProject($ProjectName, $projectFile)
Write-Host "Done."
但是,我不断收到此消息:
New-Object : Could not load file or assembly 'Microsoft.SqlServer.Dmf.Common, Version=13.0.0.0, Culture=neutral,
PublicKeyToken=89845dcd8080cc91' or one of its dependencies. The system cannot find the file specified.
At C:\Users\Brian.Ciampa\desktop\SSIS_Deploy.ps1:20 char:24
+ ... nServices = New-Object $SSISNamespace".IntegrationServices" $sqlConne ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [New-Object], FileNotFoundException
+ FullyQualifiedErrorId : System.IO.FileNotFoundException,Microsoft.PowerShell.Commands.NewObjectCommand
Microsoft.SqlServer.Dmf.dll 和 Microsoft.SqlServer.Dmf.Common.dll 文件位于该文件夹中。我需要做什么?
谢谢!布赖恩
解决方案
尝试使用 Add-Type 加载 dll,如下所示:
Add-Type -AssemblyName "Microsoft.SqlServer.Dmf.Common, Version=13.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91"
它将在当前目录中检查 dll,除非它之前已经成功加载。
如果还是找不到,则说明文件夹中的 Microsoft.SqlServer.Dmf.Common.dll 版本不是 IntegrationServices 程序集所需的 dll。
要检查当前文件夹中 dll 的签名,可以运行:
([System.Reflection.Assembly]::LoadFile((Get-Item ".\Microsoft.SqlServer.Dmf.Common.dll").FullName)).FullName
帮助定位匹配 dll 的注释。
12.0 = SQL Server 2014
13.0 = SQL Server 2016
14.0 = SQL Server 2017
备用选项:
在下面的情况下,我将首先加载 IntegrationServices“版本 14.0.0...”,这样 dll 就不需要从文件中手动加载或添加到 GAC。
C:\>attrib /s gacutil.exe
A C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6.1 Tools\x64\gacutil.exe
A C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6.1 Tools\gacutil.exe
A C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\x64\gacutil.exe
A C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\gacutil.exe
A C:\Program Files (x86)\Microsoft SDKs\Windows\v8.1A\bin\NETFX 4.5.1 Tools\x64\gacutil.exe
A C:\Program Files (x86)\Microsoft SDKs\Windows\v8.1A\bin\NETFX 4.5.1 Tools\gacutil.exe
C:\>cd "C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\x64"
C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\x64>gacutil /l | find "IntegrationServices,"
Microsoft.SqlServer.Management.IntegrationServices, Version=11.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91, processorArchitecture=MSIL
Microsoft.SqlServer.Management.IntegrationServices, Version=12.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91, processorArchitecture=MSIL
Microsoft.SqlServer.Management.IntegrationServices, Version=13.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91, processorArchitecture=MSIL
Microsoft.SqlServer.Management.IntegrationServices, Version=14.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91, processorArchitecture=MSIL
C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\x64>gacutil /l | find "Dmf.Common,"
Microsoft.SqlServer.Dmf.Common, Version=14.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91, processorArchitecture=MSIL
C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\x64>gacutil /l | find "Dmf,"
Microsoft.SqlServer.Dmf, Version=12.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91, processorArchitecture=MSIL
Microsoft.SqlServer.Dmf, Version=14.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91, processorArchitecture=MSIL
C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\x64>
推荐阅读
- javascript - 一个数组中多个对象的求和和平均值到一个数组中
- r - R:在两个列表中查找(最佳/不完全)匹配元素的索引
- c++ - 将 MemberIterator 转换为值
- javascript - 在heroku上启动时应用程序错误
- node.js - 我的脚本如何读取环境变量的更新值(由另一个进程更新)?
- firefox - Firefox 上的 VoiceOver - 将所有元素读取为可点击
- javascript - 为什么带有回调的函数没有在异步函数中执行?
- apache-spark - Spark 执行器作为尽力而为的 pod
- javascript - 按键获取深度嵌套对象的路径
- angular - Storybook Angular NX 工作区:如何使用 Chromatic 发布?