2

I have an SSIS package that calls some powershell scripts to consume web services. The problem is that when I write to stderror or stdout, the StandardErrorVariable and StandardOutputVariable are not picking up anything that is written to them from the script.

The scripts execute just fine, so it isn't a problem with calling the script it just seems as if the standard output streams are not coming back to SSIS. Here's how the Execute Process task is set up:

enter image description here

I've tried various ways of writing output from powershell. Most sources seem to indicate Write-Information should work for stdout, and I'm using mklement0's answer in this thread but have also tried Write-Error and neither worked: How do I write to standard error in PowerShell?

Any ideas?

CodeRedick
  • 7,346
  • 7
  • 46
  • 72
  • 2
    `Write-Information` does _not_ produce any output by default. Anything that produces visible output when run in a PowerShell console is (unfortunately) received as stdout output by external processes (such as SSIS in this case), even though only `Write-Output` and implicit output, i.e. output to PowerShell's _success_ (data) stream, should be - see https://github.com/PowerShell/PowerShell/issues/7989 – mklement0 Oct 13 '20 at 22:43

1 Answers1

2

I use Write-Host to output to stdout, and write-Error "Message" -ErrorAction Stop to write to stdout. I recall having issues using Write-Error without specifying that I wanted a terminating error, so try to set the ErrorPreference with each Write-Error or by setting $ErrorPreference early in your script. As mentioned in the comments there is some funkyness regarding the way powershell streams work that I do not understand/others could explain why way better than I can.

Another thing is I always set WindowStyle to Hidden. I am not sure how that would affect the stdout/err/in streams, but that has saved me other headaches when running PS from inside of SSIS.

Brandon McClure
  • 1,329
  • 1
  • 11
  • 32
  • I had "hidden" for most of my testing, had just changed it while playing with things. I had thought Write-Host was the wrong thing but that does work... thanks! – CodeRedick Oct 14 '20 at 13:29