我運行此代碼從一個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