November 7, 2020 at 6:44 pm
Are you calling Powershell from the SSIS package?
What about outputting the results into a sql table and populate variables with values from there?
November 8, 2020 at 5:01 am
Thanks for your reply. Yes, I am calling PowerShell script from SSIS (Execute Process task).
I have a couple of options that I can take.
But my point is, I am sure it must be a way to capture multiple outputs from Powershell in SSIS.
November 8, 2020 at 4:46 pm
What is the Powershell script doing - could it be changed to a script task using C#? Maybe you can use a script task and the something like the following?
using (PowerShell PowerShellInstance = PowerShell.Create())
{
string zipArchive = Dts.Variables["User::FullFileName"].Value.ToString();
string rootDirectory = Dts.Variables["$Project::RootDirectory"].Value.ToString();
// use "AddScript" to add the contents of a script file to the end of the execution pipeline.
// use "AddCommand" to add individual commands/cmdlets to the end of the execution pipeline.
PowerShellInstance.AddScript("param($zipArchive, $destinationFolder) " +
"Add-Type -assembly System.IO.Compression.FileSystem; " +
"[io.compression.zipfile]::ExtractToDirectory($zipArchive, $destinationFolder)");
PowerShellInstance.AddParameter("zipArchive", zipArchive);
PowerShellInstance.AddParameter("destinationFolder", rootDirectory);
// invoke execution
PowerShellInstance.Invoke();
}
This is an example of using Powershell to extract files from a zip archive (note: this is no longer needed since we have access to zip functionality in .NET - but does show how to instantiate an instance of Powershell).
Here is an example of returning data: https://www.codeproject.com/Questions/1206308/Powershell-commands-from-Csharp
Jeffrey Williams
“We are all faced with a series of great opportunities brilliantly disguised as impossible situations.”
― Charles R. Swindoll
How to post questions to get better answers faster
Managing Transaction Logs
November 8, 2020 at 7:59 pm
Thanks for your reply. The PowerShell script is calling a third party .exe file and getting username and PW. I will give a try using C#. However, my biggest concern is to add a "Reference" and other things when moving the Project to Prod.
I am surprised, "Execute Process task" doesn't have the functionality to capture multiple output values.
Viewing 5 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy