Run PowerShell-Script from C# Application

后端 未结 3 1934
既然无缘
既然无缘 2020-12-05 08:18

I\'m trying to execute a PowerShell script from a c# application. The script has to be executed under a special usercontext.

I\'ve tried different scenarios some are

3条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-05 08:43

    I just spent the day fixing this for myself.

    I finally was able to make it work by adding -Scope Process to Set-ExecutionPolicy

    invoker.Invoke("Set-ExecutionPolicy Unrestricted -Scope Process"); 
    

提交回复
热议问题