views:

1810

answers:

1

Does anyone know how to execute a PowerShell script from SSIS? I have created the script and it works from from the command line. The script takes a couple of command line parameters, which work fine when called from cmd.exe.

I'm using an Execute Process Task in SSIS and cannot get the script file to execute. I'm using expressions to pass in the name of the script and the command line arguments. The task is returning an incomplete string token error.

+3  A: 

From VS to launch PSH with an extra script (for a Cmdlet project) I use the following commandline:

powershell -noexit -command ". ./Startup.ps1"

The -noexit will keep the instance around (so you wouldn't want that), putting all the real commands in a script to be dot-sourced avoids a really long command line.

Richard
How would you handle command line arguments? The script expects 2 arguments.
Ed Mays
Put them in the script you dot source, this can of course call another script.
Richard
I finally figured it out. The SSIS task wants the parameters without any formatting. I was quoting the parameters and it didn't like that. Also, no embedded spaces in the arguments.
Ed Mays
@Ed Mays: Would you update the question on how you were able to pass parameters? Thanks.
Sung Meister