I am trying to set parameter value using the following code in powershell
$IspacFilePath = "D:\SSIS\MyFirstSSIS.ispac"
$ProjectName = "MyFirstSSIS"
$SsisServer = "localhost"
$SsisNamespace = "Microsoft.SqlServer.Management.IntegrationServices"
$assembly = [System.Reflection.Assembly]::LoadWithPartialName($SsisNamespace) #| Out-Null;
# Create a connection to the server
$SqlConnectionstring = "Data Source=" + $SsisServer + ";Initial Catalog=testdb;Integrated Security=SSPI;"
$SqlConnection = New-Object System.Data.SqlClient.SqlConnection $SqlConnectionstring
# Create the Integration Services object
$ssisServer = New-Object $SsisNamespace".IntegrationServices" $sqlConnection
$Catalog = $ssisServer.Catalogs["SSISDB"]
$Folder = $Catalog.Folders[$FolderName]
if($Folder.Projects.Contains($ProjectName)) {
Write-Host "Deploying" $ProjectName "to" $FolderName "(REPLACE)"
}
else
{
Write-Host "Deploying" $ProjectName "to" $FolderName "(NEW)"
}
[byte[]] $IspacFile = [System.IO.File]::ReadAllBytes($IspacFilePath)
$Folder.DeployProject($ProjectName, $IspacFile)
$Project = $Folder.Projects[$ProjectName]
foreach ($Parameter in $Project.Parameters)
{
$Parameter.ReferencedVariableName ="$SqlConnectionstring"
}
Which is giving me the result as attached, I am not getting the required configuration so can some one tell me how can I set this
Below is the code I would use to set a package level parameter, I'm assuming that it would be the same for a project level parameter:
Also for any connections you do not have to explicitly create parameters as these are created automatically for you. So for example if you had a connection called targetserver, SSIS will add a parameter to the Parameters collection called: CN.targetserver.ConnectionString.