Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
306 views
in Technique[技术] by (71.8m points)

Deploy SSIS with Powershell - Missing DMF

I'm trying to write a PowerShell script to deploy and SSIS project. Here is my code.

# Variables
$SSISNamespace = "Microsoft.SqlServer.Management.IntegrationServices"
$TargetServerName = "FBISQL003DV"
$TargetFolderName = "DEV"
$ProjectFilePath = "C:UsersBrian.CiampasourceWorkspacesTFICM2TFCIMDEVCIMSSISBC_TESTinDevelopmentBC_TEST.ispac"
$ProjectName = "BC_TEST"

# Load the IntegrationServices assembly.  This is located at C:windowsassembly.
$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."

However, I keep getting this message:

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:UsersBrian.CiampadesktopSSIS_Deploy.ps1:20 char:24
+ ... nServices = New-Object $SSISNamespace".IntegrationServices" $sqlConne ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [New-Object], FileNotFoundException
    + FullyQualifiedErrorId : System.IO.FileNotFoundException,Microsoft.PowerShell.Commands.NewObjectCommand

The Microsoft.SqlServer.Dmf.dll and the Microsoft.SqlServer.Dmf.Common.dll files are located in the folder. What do I need to do?

Thanks! Brian

question from:https://stackoverflow.com/questions/65890849/deploy-ssis-with-powershell-missing-dmf

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Try loading the dll using Add-Type like so:

Add-Type -AssemblyName "Microsoft.SqlServer.Dmf.Common, Version=13.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91"

It will check in the current directory for the dll, unless it's already been successfully loaded previously.

If you still get not found, the version of Microsoft.SqlServer.Dmf.Common.dll in the folder is not the dll needed by the IntegrationServices assembly.

To check the signature of the dll in the current folder, you can run:

([System.Reflection.Assembly]::LoadFile((Get-Item ".Microsoft.SqlServer.Dmf.Common.dll").FullName)).FullName

Notes to help locate matching dlls.

12.0 = SQL Server 2014
13.0 = SQL Server 2016
14.0 = SQL Server 2017

Alternate Option:

In the case below, I'll initially load IntegrationServices "Version 14.0.0..." so that the dll doesn't need to be manually loaded from file or added to GAC.

C:>attrib /s gacutil.exe
A            C:Program Files (x86)Microsoft SDKsWindowsv10.0AinNETFX 4.6.1 Toolsx64gacutil.exe
A            C:Program Files (x86)Microsoft SDKsWindowsv10.0AinNETFX 4.6.1 Toolsgacutil.exe
A            C:Program Files (x86)Microsoft SDKsWindowsv7.0ABinx64gacutil.exe
A            C:Program Files (x86)Microsoft SDKsWindowsv7.0ABingacutil.exe
A            C:Program Files (x86)Microsoft SDKsWindowsv8.1AinNETFX 4.5.1 Toolsx64gacutil.exe
A            C:Program Files (x86)Microsoft SDKsWindowsv8.1AinNETFX 4.5.1 Toolsgacutil.exe

C:>cd "C:Program Files (x86)Microsoft SDKsWindowsv7.0ABinx64"

C:Program Files (x86)Microsoft SDKsWindowsv7.0ABinx64>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 SDKsWindowsv7.0ABinx64>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 SDKsWindowsv7.0ABinx64>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 SDKsWindowsv7.0ABinx64>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...