Hi,
I am deploying ISPAC through VSTS via power shell script
Below is the powershell script that deploys ispac
param ( [string] $ispacpath, [string] $projectname, [string] $parameterName, [string] $AccessKeyValue, [string] $foldername, [string] $targetServerName, [string] $catalogName ) if ([string]::IsNullOrEmpty($targetServerName)) { $ServerName = "localhost"; } else { $ServerName = $targetServerName; } if ([string]::IsNullOrEmpty($catalogName)) { $SSISCatalog = "SSISDB"; } else { $SSISCatalog = $catalogName; } Write-Output "ispacpath : $ispacpath"; Write-Output "projectname : $projectname"; Write-Output "foldername : $foldername"; Write-Output "targetServerName : $ServerName"; Write-Output "catalogName : $SSISCatalog"; # Load the IntegrationServices Assembly [Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlServer.Management.IntegrationServices") # Store the IntegrationServices Assembly namespace to avoid typing it every time $ISNamespace = "Microsoft.SqlServer.Management.IntegrationServices" Write-Output "Connecting to server ..." # Create a connection to the server $sqlConnectionString = "Data Source=$ServerName;Initial Catalog=master;Integrated Security=SSPI;Network Library=DBMSSOCN;" $sqlConnection = New-Object System.Data.SqlClient.SqlConnection $sqlConnectionString $integrationServices = New-Object "$ISNamespace.IntegrationServices" $sqlConnection $catalog = $integrationServices.Catalogs[$SSISCatalog] $folder = $catalog.Folders[$foldername] if (!$folder) { #Create a folder in SSISDB Write-Output "Creating Folder ..." $folder = New-Object "$ISNamespace.CatalogFolder" ($catalog, $foldername, $foldername) $folder.Create() } # Read the project file, and deploy it to the folder Write-Output "Deploying Project ..." [byte[]] $projectFile = [System.IO.File]::ReadAllBytes($ispacpath) $folder.DeployProject($projectname, $projectFile) $project = $folder.Projects[$projectName] $project.Parameters[$parameterName].Set( [Microsoft.SqlServer.Management.IntegrationServices.ParameterInfo+ParameterValueType]::Literal, $AccessKeyValue) $project.Alter()
In VSTS, we are using the task "PoweShell On Target Machines".
In PowerShell Script value is : D:\ReleaseManagement\AgentLib\DeployIspacToSSISDB.ps1
(DeployIspacToSSISDB.ps1 has the code that is pasted in code block)
In Script Arguments value is : "D:\ReleaseManagement\TestMart.ispac" "TestMart" "TestKey" "labcd/xyz=" "Test"
But when we try to deploy using VSTS, it is getting failed with the error
System.Management.Automation.RuntimeException: Exception calling ".ctor" with "3" argument(s): "The property 'Name' contains invalid characters as an object name. Remove the invalid characters." ---> System.Management.Automation.RuntimeException: Exception calling ".ctor" with "3" argument(s): "The property 'Name' contains invalid characters as an object name. Remove the invalid characters." |
LegacyVSTSPowerShellHost.exe completed with return code: -1. |
NOTE:
ISPAC is successfullly deployed when powershell script is executed manually as below
D:\ReleaseManagement\AgentLib\DeployIspacToSSISDB.ps1 "D:\ReleaseManagement\TestMart.ispac" "TestMart" "TestKey" "labcd/xyz=" "Test"
Raksha