Return to Snippet

Revision: 28529
at July 9, 2010 04:16 by markshoe


Updated Code
string cmdArg = ".\script.ps1 -foo bar" �  �  �  �  �  � 
Collection<PSObject> psresults;
using (Pipeline pipeline = _runspace.CreatePipeline())
�  �  �  �  �  �  {
�  �  �  �  �  �  �  �  pipeline.Commands.AddScript(cmdArg);
�  �  �  �  �  �  �  �  pipeline.Commands[0].MergeMyResults(PipelineResultTypes.Error, PipelineResultTypes.Output);
�  �  �  �  �  �  �  �  psresults = pipeline.Invoke();
�  �  �  �  �  �  }
return psresults;

Revision: 28528
at July 9, 2010 04:15 by markshoe


Updated Code
string cmdArg = ".\script.ps1 -foo bar"            
Collection<PSObject> psresults;
using (Pipeline pipeline = _runspace.CreatePipeline())
            {
                pipeline.Commands.AddScript(cmdArg);
                pipeline.Commands[0].MergeMyResults(PipelineResultTypes.Error, PipelineResultTypes.Output);
                psresults = pipeline.Invoke();
            }
return psresults;

Revision: 28527
at July 9, 2010 04:13 by markshoe


Initial Code
string cmdArg = ".\script.ps1 -foo bar"            
Collection<PSObject> psresults;
using (Pipeline pipeline = _runspace.CreatePipeline())
            {
                pipeline.Commands.AddScript(cmdArg);
                pipeline.Commands[0].MergeMyResults(PipelineResultTypes.Error, PipelineResultTypes.Output);
                psresults = pipeline.Invoke();
            }
return psresults;

Initial URL

                                

Initial Description

                                

Initial Title
Execute a powershell script from c#

Initial Tags

                                

Initial Language
C#