简体   繁体   English

Powershell远程会话外部命令执行

[英]Powershell remote session external command execution

I've been playing around with powershell remoting and I've come across a problem that I am unable to resolve. 我一直在玩Powershell远程处理,遇到了一个我无法解决的问题。 I have a script that creates a remote session and after setting up some variables does the following: 我有一个创建远程会话的脚本,并在设置了一些变量之后执行以下操作:

Invoke-Command -Session $remote_session -ScriptBlock $block -ArgumentList $args

Within the block everything works fine except when it comes to a specific line, at which point the script hangs. 在该块中,所有功能都可以正常工作,除非涉及到特定行,此时脚本将挂起。 The pertinent line is: 相关行是:

& '.\external_command.exe' $argument_list

When I log into the computer that is hosting the remote powershell session I can see external_command.exe in the process list but it's not doing anything. 当我登录到托管远程Powershell会话的计算机时,我可以在进程列表中看到external_command.exe ,但它没有执行任何操作。 Does anyone have any ideas on how to resolve the issue? 是否有人对解决问题有任何想法?

I had similar problems with remote execution of installers. 我对安装程序的远程执行有类似的问题。 As a workaround I now first create a cmd batch file through powershell and then run this batch file. 作为一种解决方法,我现在首先通过powershell创建一个cmd批处理文件,然后运行该批处理文件。 Something like this: 像这样:

"c:\external_command.exe argument1" > c:\run.cmd
&"c:\Run.cmd" |Out-Null 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM