Разверните и установите свойство Ispac connectionstring на вкладке Диспетчер подключений с помощью Powershell - PullRequest
0 голосов
/ 23 ноября 2018

Я могу успешно развернуть проект ssis с powershell, используя приведенный ниже код, однако я также хотел установить свойство 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."

1 Ответ

0 голосов
/ 26 ноября 2018

получил это работает.просто нужно установить значение для параметра CM.ConfigurationDatabase.ConnectionString.

$Project = $folder.Projects[$ProjectName]

$cm_value = "test"

$Project.Parameters["CM.ConfigurationDatabase.ConnectionString"].Set([Microsoft.SqlServer.Management.IntegrationServices.ParameterInfo+ParameterValueType]::Literal, $cm_value)
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...