Out Of Memory while compiling method

While running a command like this one

Invoke-Command -ComputerName remotemachine -Credential $cred -scriptBlock {& C:\Windows\Microsoft.Net\Framework64\v4.0.30319\ngen.exe install C:\Assemblies\my.dll /verbose}

we encounter this error “Out Of Memory while compiling method …”

If we run the command locally on the remotemachine it works fine.

Anyone have any suggestions?

Hello!

You might be running out of memory in the remote session, try the following:

Get-Item wsman:localhost\Shell\MaxMemoryPerShellMB

You can then set the maxvalue with this command and see if it helps:

Set-Item wsman:localhost\Shell\MaxMemoryPerShellMB 1024

Where 1024 is an example value.

/Alexander