We can manually take backup of existing "Integration Services Catalogs project" by right click on it and give "export" option which will give an .ispac file.
I am trying to automate this export operation by using below powershell script.
Param( [Parameter(Mandatory=$true,ValueFromPipeline=$true)] [string]$Datasource = $null, [Parameter(Mandatory=$true)] [string]$MasterDBName = $null, [Parameter(Mandatory=$true)] [string]$SSISDBName = $null, [Parameter(Mandatory=$true)] [string]$FolderName = $null, [Parameter(Mandatory=$true)] [string]$ProjectName = $null, [Parameter(Mandatory=$true)] [string]$DestinationPath = $null ) # Load the IntegrationServices Assembly [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlServer.Management.IntegrationServices") | Out-Null; # Store the IntegrationServices Assembly namespace to avoid typing it every time $ISNamespace = "Microsoft.SqlServer.Management.IntegrationServices" Write-Host "Connecting to server ..." # Create a connection to the server $sqlConnectionString = "Data Source=$Datasource;Initial Catalog=$MasterDBName;Integrated Security=SSPI;" $sqlConnection = New-Object System.Data.SqlClient.SqlConnection $sqlConnectionString # Create the Integration Services object $integrationServices = New-Object $ISNamespace".IntegrationServices" $sqlConnection $catalog = $integrationServices.Catalogs[$SSISDBName] $fld = $catalog.Folders[$FolderName] $prj = $fld.Projects[$ProjectName] $ispacfilename = "test.ispac" $ispacfullpath = Join-Path $DestinationPath $ispacfilename Write-Host "ispacfullpath $ispacfullpath" $xmlwriter = [System.Xml.XmlWriter]::Create($ispacfullpath) $prj.Serialize($xmlwriter) $xmlwriter.Close()
While execution it throws the below error
Exception calling "Serialize" with "1" argument(s): "The parameter 'sink.Action' is invalid." At C:\T_ISCRMS_SSIS2012_Export.ps1:46 char:1+ $prj.Serialize($xmlwriter)+ ~~~~~~~~~~~~~~~~~~~~~~~~~~+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException+ FullyQualifiedErrorId : IntegrationServicesException
I understand that Serialize method accepts only System.Xml.XmlWriter object.
Please let me know how i can export/serialize to a ispac file which is based on binary serialization.
Reference:
https://msdn.microsoft.com/en-us/library/microsoft.sqlserver.management.integrationservices.projectinfo(v=sql.110).aspx
https://msdn.microsoft.com/en-us/library/microsoft.sqlserver.management.sdk.sfc.sfcinstance.serialize(v=sql.110).aspx