gpt4 book ai didi

powershell - 使用Powershell在“连接管理器”选项卡中部署并设置Ispac connectionstring属性

转载 作者:行者123 更新时间:2023-12-02 23:36:43 26 4
gpt4 key购买 nike

我可以使用下面的代码用powershell成功地部署ssis项目,但是,我也想在“连接管理器”选项卡中设置connectionstring属性(在项目级别)。我试图搜索,但找不到任何来源。有人可以帮忙吗? enter image description here

# Variables
$SSISNamespace = "Microsoft.SqlServer.Management.IntegrationServices"

$TargetServerName = "localhost"
$TargetFolderName = "Project1Folder"
$ProjectFilePath = "C:\Projects\Integration Services Project1\Integration Services Project1\bin\Development\Integration Services Project1.ispac"
$ProjectName = "Integration Services Project1"

# Load the IntegrationServices assembly
$loadStatus = [System.Reflection.Assembly]::Load("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)

Write-Host "Done."

最佳答案

得到这个工作。只需要设置CM.Configuration Database.Connection String参数的值即可。

$Project = $folder.Projects[$ProjectName]

$cm_value = "test"

$Project.Parameters["CM.ConfigurationDatabase.ConnectionString"].Set([Microsoft.SqlServer.Management.IntegrationServices.ParameterInfo+ParameterValueType]::Literal, $cm_value)

关于powershell - 使用Powershell在“连接管理器”选项卡中部署并设置Ispac connectionstring属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53444199/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com