使用Powershell Invoke-Command远程执行时OutOfMemory异常 [英] OutOfMemory Exception on remote execution using Powershell Invoke-Command

查看:221
本文介绍了使用Powershell Invoke-Command远程执行时OutOfMemory异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用invoke-command在远程计算机上执行exe.使用远程桌面登录计算机后,在远程计算机上执行exe会占用1GB内存,并在一分钟后执行完毕.而当我在同一台计算机上使用Invoke-Command执行同一exe时,该过程将返回OutOfMemoryException并突然结束.我的invoke命令就像Invoke-Command -Session $someSessionVariable -ScriptBlock {Invoke-Expression "abc.exe --arg arg"} -AsJob一样简单.

I am trying to execute an exe on a remote computer using invoke-command. Executing the exe on the remote machine after logging into the machine using remote desktop takes 1GB of memory and executes to completion after a minute. Whereas when I execute the same exe using Invoke-Command on the same machine, the process returns an OutOfMemoryException and ends suddenly. My invoke command is as simple as Invoke-Command -Session $someSessionVariable -ScriptBlock {Invoke-Expression "abc.exe --arg arg"} -AsJob.

我是否缺少有关远程调用限制的信息?

Am I missing something regarding the restrictions on remote invocation?

在此先感谢.

推荐答案

基于 mjolinor 的答案的完整PowerShell脚本,适用于希望跳过原因并使其起作用的任何人:

Complete PowerShell script, based on mjolinor's answer, for anyone who wants to skip the reasons and just make it work:

Set-Item WSMan:\localhost\Shell\MaxMemoryPerShellMB 1000000
Set-Item WSMan:\localhost\Plugin\Microsoft.PowerShell\Quotas\MaxMemoryPerShellMB 1000000
Restart-Service WinRM

这篇关于使用Powershell Invoke-Command远程执行时OutOfMemory异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆