I would like to list SqlStatementSource of all "Execute SQL Task" in SSIS package. By referencing relevant, it shows the ssis package of SQLPSX may be helpful to resolve this task. However, while I am trying to do the following procedure:
import-module SSIS
$package = Get-ISPackage -path "xxx.dtsx"
My powershell returns an error message of:
"Failed to remove package protection with error 0xC0014037 "The package is encrypted with a password. The password was not specified, or is not correct.". This occurs in the CPackage::LoadFromXML method."
it shows I should import password to decrypt the package to retrieve data, but where should I put the password? Or is there any other convenient solution for me to solve the issue.
Best, David
you usually use DTEXEC to run an encrypted package like this:
/FILE means the package is on the file system. You would use /SQL to a package on the SQl Server database or /DT if it is on the file store
Also if you open the package on BIDS, you should be prompted for a password
After searching online information about how to list all SSIS component, I found writing a C# program might be the best solution to solve the problem. Therefore, below I wrote a VS 2008 compatible program to finish my task. Below written the program which will list all SSIS related component, and write the result to excel file. The solution will save you a lot of time clicking on component shown in VS 2008 to view component property one by one. Since I am not a C# expert, the program may not well coded. But at least it works!
I don't have SQLPSX installed but I can tell you how to decrypt the package without it. The important thing to do is to assign the package password to the application and so that it can decrypt the package.
Given a package like this where each execute sql task has a statement of
SELECT N AS test
The following script will decrypt a package saved as EncryptAllWithPassword and has an assortment of tasks with some embedded in various containers. It's not beautiful PowerShell by any stretch but it gets the job done.
Ouput
Not that this is the best solution but something to try. Instead of trying to go through SSIS to obtain the information why not go through the file itself. DTSX files are XML format and PowerShell plays pretty well with these type files.
I tried this on one of my dtsx files and was able to return information:
For some reason I do get an InvalidArgument error saying it cannot find the property "SqlTaskData". I believe this is from it hitting the data flow task I have in the package, and it does not have the property/attribute. This is what I mean in that it might not be the perfect solution, so I offer no guarantees. One thing to point out is I do not have my packages set to be encrypted by a password.
Update
You might try SQLPSX that include a library for SSIS.