How to debug PowerShell scripts in SSIS

I will skip the basics as this Microsoft blog did a good job explaining how to Run PowerShell scripts in SSIS .

Ok, now you have a powershell script running inside SSIS and soon enough you will need to deal with errors. By default you don’t get a lot from SSIS as the process popup window specified by WindowStyle normally gives you a glimpse of the error messages milliseconds before it terminates.

The first reaction I usually see people do is trying to make the popup window to stay/wait/hold, but instead of going down the fruitless path, here is what you can do:

1. Setup variables for StandardOutputVariable and StandardErrorVariable

2. Set a breakpoint on the condition Break when the container receives the OnPostExecute event 

3. Start Debugging (Note: Don’t right-click and Execute Task) and wait for the breakpoint to be hit.

4 .Inspect the variables in the Locals window