5

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.

2
  • SQL Server Integration Services. A Microsoft Tool/Platform for moving data in and out of SQL Server. Commented Mar 3, 2009 at 5:16
  • What command line are you processing to the execute process task? Commented Mar 3, 2009 at 14:21

2 Answers 2

5

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.

Sign up to request clarification or add additional context in comments.

5 Comments

How would you handle command line arguments? The script expects 2 arguments.
Put them in the script you dot source, this can of course call another script.
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: Would you update the question on how you were able to pass parameters? Thanks.
This answer does nothing to explain how the parameters are passed from ssis. putting them in the script isn't optimal if the parameters originate in SSIS process
2

Go to Execute Process Task Editor -> Process tab and set the following options:

  • Executable - C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
  • Arguments - -File ".\PowershellScript/ps1" "arg_1_value" "arg_2_value" ... "arg_n_value"

Refer to the below screenshot: enter image description here

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.