【发布时间】:2016-01-20 14:56:16
【问题描述】:
我尝试使用 c# 程序中的参数文件启动 ps1。但在此之前,我尝试将其做得更小,并运行“ls”。但它不起作用,我认为我的代码还可以。
pipeline.Commands.Add("ls ."); //in future here path of .ps1 file + arguments
Collection<PSObject> results;
// Execute PowerShell script
results = pipeline.Invoke();
//print it in a textbox
AppendLine(results.ToString());
我使用像参考Execute PowerShell Script from C# with Commandline Arguments
错误是“System.Management.Automation.CommandNotFoundException: 'ls .'不是 cmdlet、函数或 bat 文件。
【问题讨论】:
标签: c# powershell command-line scripting arguments