question

PadmanabhanVenkatesh-6789 avatar image
0 Votes"
PadmanabhanVenkatesh-6789 asked IanXue-MSFT answered

Edit SSIS package using powershell

Hi.
I have around 200 SSIS packages, in which I want to make few edits.

I am trying to check if Powershell can solve this issue. I have a specific location in which all my SSIS packages are kept. In each of the SSIS package, there is a GetConnection method. Inside the method , I want to find the first instance of the text GetConnection = strConnection , and add another connection string property before it and save the file.

This process should be repeated for all the files. How to achieve this in Powershell ?
Thanks

windows-server-powershellsql-server-integration-services
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

OlafHelper-2800 avatar image
0 Votes"
OlafHelper-2800 answered PadmanabhanVenkatesh-6789 commented

SSIS packages are XML files and PowerShell have a good support to handle & modify XML files.
See for example https://stackoverflow.com/questions/16428559/powershell-script-to-update-xml-file-content

· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

HI .
Thanks for the reply. How to match a particular line of code and then update .

example: I have the following lines,
If Abc_NM = "" Then
strConnectionInfo = "Not Found"
End If

I want to add my code post this line. How to match this line ?
Thanks

0 Votes 0 ·
IanXue-MSFT avatar image
0 Votes"
IanXue-MSFT answered

Hi,

You can match text with a regular expression. Please refer to this link for more details.
https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_regular_expressions

Best Regards,
Ian Xue
============================================
If the Answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.