【发布时间】:2014-12-09 18:58:45
【问题描述】:
我正在使用open-device 127.0.0.1 连接远程设备。如何从 C# 调用它?这段代码:
PowerShell powerShell = PowerShell.Create();
PSCommand connect = new PSCommand();
connect.AddCommand("open-device");
powerShell.Commands = connect;
PSOutput = powerShell.Invoke()
导致错误:
System.Management.Automation.CommandNotFoundException:术语open-device未被识别为 cmdlet、函数、脚本文件或可运行程序的名称。检查名称的拼写,如果包含路径,请验证路径是否正确,然后重试。atSystem.Management.Automation.Runspaces.PipelineBase.Invoke(IEnumerable input) at System.Management.Automation.Runspaces.Pipeline.Invoke() at System.Management.Automation.PowerShell.Worker.ConstructPipelineAndDoWork(Runspace rs, Boolean performSyncInvoke)
但是,我可以使用Invoke 运行get-service 命令。
【问题讨论】:
-
离题,但我想知道:
127.0.0.1(又名localhost)似乎不是很遥远......?
标签: c# powershell powershell-3.0