[英]remote execution(PowerShell) of cmd file doesn't complete
Current PS script: 当前的PS脚本:
Invoke-Command -ComputerName RemoteServer007.FQDN.com -ScriptBlock {
Set-Variable -Name WOWCONFIG -value "d:\ABCs\WOWzers" `
| Start-Process "d:\da-folder\Do-It-NOW-Pleez.cmd"
}
If I log on locally to the server(RemoteServer007.FQDN.com) and execute the cmd file, it runs through all of the lines(commands) within the cmd file. 如果我本地登录到服务器(RemoteServer007.FQDN.com)并执行该cmd文件,则它将运行该cmd文件中的所有行(命令)。
When I execute it remotely, it gets about 30% of the way through the commands within the cmd file, the PS execution ends without error, but not all of the lines/commands in the cmd file had been executed. 当我远程执行它时,它将通过cmd文件中的命令完成大约30%的操作,PS执行无错误结束,但不是cmd文件中的所有行/命令都已执行。
This was discovered by simply configuring each line of the cmd file to output to txt files. 这是通过简单配置cmd文件的每一行以输出到txt文件而发现的。 I even tried re-ranging the commands in the cmd file, thinking that perhaps there was a specific command that was causing it to exit, but that is not the case.
我什至尝试重新调整cmd文件中的命令范围,以为可能是某个特定的命令导致该命令退出,但是事实并非如此。
I'm wondering if there is some timeout or response that PowerShell is not getting? 我想知道PowerShell是否没有超时或响应? and just quitting almost immediately after starting?
并在开始后几乎立即退出?
Any ideas or help would be greatly appreciated. 任何想法或帮助将不胜感激。
There are a couple of things you can do here: 您可以在这里做几件事:
You may have a memory issue. 您可能有内存问题。 Increasing the value of MaxMemoryPerShellMB might help
增加MaxMemoryPerShellMB的值可能会有所帮助
set-item WSMan:\\$target\\Shell\\MaxMemoryPerShellMB -Value 0 -Force 设置项目WSMan:\\ $ target \\ Shell \\ MaxMemoryPerShellMB-值0-强制
You'd need to run this once on the remote machine before you execute your commands again. 您需要在远程计算机上运行一次,然后再次执行命令。
You can also see possible error logs in the windows event viewer. 您还可以在Windows事件查看器中查看可能的错误日志。 There are categories for powershell and for Windows Remote Management which you should look at.
您应该查看有关powershell和Windows远程管理的类别。
Finally, you can just run this process asynchronously, using the task scheduler for instance. 最后,您可以使用例如任务计划程序异步运行此过程。 I had a similar problem with windows in the past, and running the process from the task scheduler, outside the powershell session, fixed it.
过去,我在Windows上也遇到过类似的问题,并且在powershell会话外部通过任务计划程序运行了该进程,并对其进行了修复。 There's an example of how we did this in Cloudify here: https://github.com/CloudifySource/cloudify/blob/master/esc/src/main/resources/clouds/ec2-win/upload/bootstrap-management.ps1#L220
这里有一个关于我们如何在Cloudify中执行此操作的示例: https : //github.com/CloudifySource/cloudify/blob/master/esc/src/main/resources/clouds/ec2-win/upload/bootstrap-management.ps1# L220
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.