更新时间:2022-12-22 23:01:14
我认为您缺少PowerShell
实例与运行空间的绑定.
I think that you are missing the bind of your PowerShell
instance to the runspace.
ps.Runspace = runspace;
Take a look to this for more details.
或者,您也可以创建管道(如此处)使用运行空间并调用命令.
Alternatively, you can create a Pipeline (as explained here) using the runspace and invoke the commands.
Pipeline pipeline = runspace.CreatePipeline("<COMMAND TO EXECUTE REMOTELY>");
var results = pipeline.Invoke();