简体   繁体   中英

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. 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. 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. Something like this:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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