Run Powershell from C# -


I need to start the parcel script from c # and get PSSSecurityException on the pipeline. Invoke ()

Authorization Manager check failed.

My code:

  RunSpecify configuration RSSP configuration = Ranspace configuration. Create (); (Ranspace Ranspace = Ranspacefitter. Criterionpresses (Ranspace Configuration)) {runpace.Open (); Pipeline pipeline = ranspace CretePipline (); Command script command = new command (scriptfile); Pipeline.Commands.Add (scriptCommand); Pipeline.Invoke (); }  

question

  1. I suspect that I need to set PSCredential. But I can not prompt for this, so handle me in this code. Have to do. Can it be done in a safe way? ( was not the case )

refer to this superfast post :

You probably need to allow unsigned scripts to run. In the PS console, type the following:

  Set-Execution Policy Rethoscid  

Another resource indicates:

Try and tell me what happens.

To capture the output from the script, try it:

  Storage output = Pipeline. Invoke (); Forehatch (PS object PO object in output) {& lt; Here you can do toosting poobias for the output and it will have your log & gt; }  

Comments