如何通过 Powershell Remoting 运行 7za.exe?
我尝试了多种不同的方法来执行此操作,它们都会导致相同的错误。 这是一组命令:
$s = New-PSsession -ComputerName ServerA
$job = Invoke-Command -Session $s -Scriptblock { Start-Process -FilePath
"C:\Scripts\ArchiveEventLogs\ver4.5\7za.exe" -ArgumentList "a",
"C:\Scripts\Eventlogs.bak\ServerA-20101111.7z", "C:\Scripts\Eventlogs.bak\*.evt*",
"-mx7", "-oC:\Scripts\Eventlogs.bak", "-wC:\Scripts\Eventlogs.bak", "-t7z" -Wait }
-AsJob
Get-Job | Wait-Job
Receive-Job Job$
我得到的输出是这样的:
7-Zip (A) 9.17 beta Copyright (c) 1999-2010 Igor Pavlov 2010-10-04
Scanning
Creating archive C:\Scripts\Eventlogs.bak\ServerA-20101111.7z
ERROR: Can't allocate required memory!
我怎样才能克服这个错误???
我应该指出,如果我直接在 ServerA 上运行 Scriptblock 而无需远程处理,它就可以工作。 感谢您的帮助!
I've tried a number of different ways to do this, they all result in the same error.
Here is one set of commands:
$s = New-PSsession -ComputerName ServerA
$job = Invoke-Command -Session $s -Scriptblock { Start-Process -FilePath
"C:\Scripts\ArchiveEventLogs\ver4.5\7za.exe" -ArgumentList "a",
"C:\Scripts\Eventlogs.bak\ServerA-20101111.7z", "C:\Scripts\Eventlogs.bak\*.evt*",
"-mx7", "-oC:\Scripts\Eventlogs.bak", "-wC:\Scripts\Eventlogs.bak", "-t7z" -Wait }
-AsJob
Get-Job | Wait-Job
Receive-Job Job$
The output I get is this:
7-Zip (A) 9.17 beta Copyright (c) 1999-2010 Igor Pavlov 2010-10-04
Scanning
Creating archive C:\Scripts\Eventlogs.bak\ServerA-20101111.7z
ERROR: Can't allocate required memory!
How can I get past that error???
I should point out, if I run the Scriptblock directly on ServerA without the remoting, it works.
Thanks for any help!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
默认情况下,远程 shell 的内存限制为 150 MB。您可以使用服务器上的 winrm 命令行实用程序对此进行调整;我不确定 powershell wsman:\ 驱动器是否会让您以交互方式更改此设置,因为我认为这是 winrm 中 shell 插件功能的一般属性,而不是直接连接到 powershell。
压缩大文件是一个非常消耗内存的过程。
Remote shells are limited to 150 MB of memory by default. You can tweak this with the winrm command-line utility on the server; I'm not sure if the powershell wsman:\ drive will let you change this interactively because I think it's a general property of the shell plugin functionality in winrm and not directly connected to powershell.
Compressing large files is a memory-hungry process.
另一个解决方案是更改 Windows 远程 Shell 的配置。
您可以在远程服务器上的 PowerShell 提示符下执行以下命令:
如果您不想通过组策略应用更改,这尤其有用。
Ps:要查看当前配置的值是什么,请尝试执行以下命令:
Another solution is to change the configuraiton of the Windows Remote Shell.
You could execute the following in a PowerShell prompt on the remote server:
This is especially useful if you don't want to apply the change via Group Policy.
Ps: To see what the currently configured value is try executing the following: