Posted By

markshoe on 07/09/10


Tagged

PowerShellcscript


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

Tyster


Execute a powershell script from c#


 / Published in: C#
 

  1. string cmdArg = ".\script.ps1 -foo bar" �  �  �  �  �  � 
  2. Collection<PSObject> psresults;
  3. using (Pipeline pipeline = _runspace.CreatePipeline())
  4. �  �  �  �  �  �  {
  5. �  �  �  �  �  �  �  �  pipeline.Commands.AddScript(cmdArg);
  6. �  �  �  �  �  �  �  �  pipeline.Commands[0].MergeMyResults(PipelineResultTypes.Error, PipelineResultTypes.Output);
  7. �  �  �  �  �  �  �  �  psresults = pipeline.Invoke();
  8. �  �  �  �  �  �  }
  9. return psresults;

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: Vordreller on July 9, 2010

Might wanna look at what you just now pasted here in UTF-8 browser setting :P

You need to login to post a comment.