hi,
i'm using this code to run powershell script from a workflow using the run code component.
my code is:
// Source: http://www.codeproject.com/KB/cs/HowToRunPowerShel...
// create Powershell runspace
Runspace runspace = RunspaceFactory.CreateRunspace();
// open it
runspace.Open();
// create a pipeline and feed it the script text
Pipeline pipeline = runspace.CreatePipeline();
pipeline.Commands.AddScript(PSInput);
// add an extra command to transform the script
// output objects into nicely formatted strings
// remove this line to get the actual objects
// that the script returns. For example, the script
// "Get-Process" returns a collection
// of System.Diagnostics.Process instances.
pipeline.Commands.Add("Out-String");
// execute the script
Collection<PSObject> results = pipeline.Invoke();
// close the runspace
runspace.Close();
// convert the script result into a single string
StringBuilder stringBuilder = new StringBuilder();
foreach (PSObject obj in results)
{
stringBuilder.AppendLine(obj.ToString());
}
return stringBuilder.ToString();
the problem is that the code run OK in debug mode but when publishing to iis i get the following error:
System.Exception: Execution Engine Exception ---> System.Exception: Execution Exception ---> System.Exception: exception component created: ---> LogicBase.Framework.BusinessRuleException: The critical error failed execution on component Code (Script) Component : Exception has been thrown by the target of an invocation. : at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters)
at LogicBase.Components.Scripting.ScriptedComponent.Run(IData data)
at LogicBase.Core.ExecutionEngine.SinglePathProcessComponentExecutionDelegate.Execute(IData data, IOrchestrationComponent comp, String& outputPath, IExecutionEngine engine, TLExecutionContext context)
at LogicBase.Core.ExecutionEngine.AbstractExecutionEngine.RunComponent(TLExecutionContext context, IData data, IOrchestrationComponent comp)
--- End of inner exception stack trace ---
at LogicBase.Core.ExecutionEngine.ExceptionComponentDelegate.Execute(IData data, IOrchestrationComponent comp, String& outputPath, IExecutionEngine engine, TLExecutionContext context)
--- End of inner exception stack trace ---
at LogicBase.Core.ExecutionEngine.AbstractExecutionEngine.RunEngine(List`1 executionQueue)
--- End of inner exception stack trace ---
at LogicBase.Core.ExecutionEngine.AbstractExecutionEngine.RunEngine(List`1 executionQueue)
at LogicBase.Core.ExecutionEngine.AbstractExecutionEngine.ExecuteComponent(IData data, IOrchestrationComponent component)
at LogicBase.Core.Models.Workflow.WorkflowExecutionEngine.StartInternal(String trackingId, IData data, String modelName, IData globalData, String testRunId, TestingScenario testingScenario)
at LogicBase.Core.Models.Workflow.WorkflowExecutionEngine.Start(IData data, String modelName)
can anyone help? is there a native powershell component i can use?
thanks
mordechai