Some memory errors might occur using using the invoke-command PowerShell cmdlet to run programs or scripts on remote hosts. By default a remote session is default limited to 150MB. For example when trying to run java application remote.
Invoke-Command -ComputerName MyServer-ScriptBlock {java}
Error occurred during initialization of VM
Could not reserve enough space for object heap
To solve this setting the MaxMemoryPerShellMB option for remote shell connections to a larger amount. This comment must be run on the remote system with administrator rights.
Powershell
set-item wsman:localhost\Shell\MaxMemoryPerShellMB 2048
Batch
winrm set winrm/config/winrs @{MaxMemoryPerShellMB="2048"}
Now trying again to run invoke-command to the remote server yields better results.
Invoke-Command -ComputerName MyServer -ScriptBlock {java}
Usage: java [-options] class [args...]
(to execute a class)
or java [-options] -jar jarfile [args...]
(to execute a jar file)
This can be affect by using PowerShell ISE Remote PowerShell Tab also.

0 comments:
Post a Comment