使用PowerShell部署SSIS软件包

时间:2020-09-16 14:06:42

标签: sql-server powershell ssis ssms

我正在尝试通过PowerShell将.ispac文件部署到SQL Server(2017)。到目前为止,我已经下载了SQL Server PowerShell模块,当然还安装了SSIS(版本15.0.2000.93)。

我要运行的PowerShell脚本与文档中的脚本几乎相同:

# Variables
$SSISNamespace = "Microsoft.SqlServer.Management.IntegrationServices"
$TargetServerName = "name"
$TargetFolderName = "name"
$ProjectFilePath = "path"
$ProjectName = "name"

# Load the IntegrationServices assembly
$loadStatus = [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SQLServer.Management.IntegrationServices, "+
    "Version=14.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)

该错误发生在第18行:

$integrationServices = New-Object $SSISNamespace".IntegrationServices" $sqlConnection

并说找不到该程序集或其依赖项(见下文):

“ Microsoft.SqlServer.Dmf.Common,版本= 13.0.0.0,区域性=中性, PublicKeyToken = 89845dcd8080cc91“

此外,当我通过右键单击SSMS(18.5)中的Integration Services目录尝试“启动PowerShell”时,出现错误:

值不能为null。参数名称:value(mscorlib)

我不知道是否以某种方式连接了错误,但我希望它有助于发现问题。 我以管理员身份运行PowerShell,对读取或执行DLL没有任何限制。

非常感谢,您可以给我任何提示,我感到满意!

0 个答案:

没有答案