Ed Mays
Ed Mays

Reputation: 1760

How to Execute a PowerShell Script from SSIS

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.

Upvotes: 5

Views: 18226

Answers (2)

Dmytro Sly
Dmytro Sly

Reputation: 303

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

Upvotes: 1

Richard
Richard

Reputation: 109005

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.

Upvotes: 5

Related Questions