我运行此代码从一个asp.net应用程序执行电源外壳:.ps1无法加载,因为在此系统上禁用了脚本的执行?
System.Management.Automation.Runspaces.Runspace runspace = System.Management.Automation.Runspaces.RunspaceFactory.CreateRunspace();
runspace.Open();
System.Management.Automation.Runspaces.Pipeline pipeline = runspace.CreatePipeline();
pipeline.Commands.AddScript(@"\\servername\path");
pipeline.Commands.Add("Out-String");
Collection<PSObject> results = pipeline.Invoke();
runspace.Close();
但我得到的错误:
.ps1 cannot be loaded because the execution of scripts is disabled on this system. Please see "get-help about_signing" for more details.
相同的代码运行在命令提示符下或Windows罚款(winform)应用程序。
这不适合我。嗯,实际上如果你把它设置为32位和64位,它确实能工作。 – 2016-02-12 08:45:28