Solved

SSIS capture PowerShell output

Posted on 2014-04-16
3
1,680 Views
Last Modified: 2016-02-10
I  am testing to see if it is possible to capture PS output in SSIS. I am an SSIS newbie. I created a script with one line of code:

test.ps1
$result = Write-Output "Exit"

I can run test.ps1 successfully from an Execute Process Task.
Here is how I set up the Execute Task:

Executable = %SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe
Arguments = -file "C:\Scripts\testing\SSIS\SSIS_Test.ps1"
StandardOutputVariable = User::Result

User::Result Variable I created in the Execute Task:
Container = Package
Name = Result
Namespace = User
Value Type = String

I have created an Execute SQL Task to insert the results in a test database. Using:

SQLSourceType = Direct input
SQLStatement = INSERT INTO dbo.Table_1(test) VALUES (?)

and a Parameter Mapping in the Execute SQL Task
VN = User::Result
Direction = Output
Data Type = Long
Paramter Name = 0
Parameter Size = -1

The workflow runs but the output is a null value.

How can I capture the output of $Result for the PS script into a variable in SSIS and use that variable to update a DB??

Thanks
0
Comment
Question by:greetrufus
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 22

Expert Comment

by:plusone3055
ID: 40003934
greetings.

Please take a look at this article from databasse journal

I think it may contain the information you are looking for :)

http://www.databasejournal.com/features/mssql/ssis-2012-using-powershell-to-configure-project-environments.html
0
 

Accepted Solution

by:
greetrufus earned 0 total points
ID: 40034482
I was able to accomplish this by creating a variable (User::PSOutput) in the StandardOutputVariable. of the Execute Process Task.

I created a Precedence Constraint from the EPT and used an Expression.
I was unable to query off the exact output, but was able to query using NotNull
So I created the following Expression:
@[User::PSOutput] != ""

This PC was connect to a send mail step that would send an email and capture the PSOutput variable as the subject of the email.

On a second PS, I added the opposite Expression:
@[User::PSOutput] == ""

So if the PSOutput was null, the package would continue.

This did force me to write very clean PowerShell code with no outputs except for errors.

Hope this helps someone else!!
0
 

Author Closing Comment

by:greetrufus
ID: 40043928
No one else gave a more suitable answer
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A couple of weeks ago, my client requested me to implement a SSIS package that allows them to download their files from a FTP server and archives them. Microsoft SSIS is the powerful tool which allows us to proceed multiple files at same time even w…
The following article is intended as a guide to using PowerShell as a more versatile and reliable form of application detection in SCCM.
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question