Use below Powershell CLI command to configure maximum powershell memory.
PS C:\> sl WSMan:\localhost\Shell
PS WSMan:\localhost\Shell> dir
WSManConfig: Microsoft.WSMan.Management\WSMan::localhost\Shell
Type Name SourceOfValue Value
---- ---- ------------- -----
System.String AllowRemoteShellAccess true
System.String IdleTimeout 7200000
System.String MaxConcurrentUsers 10
System.String MaxShellRunTime 2147483647
System.String MaxProcessesPerShell 25
System.String MaxMemoryPerShellMB 512
System.String MaxShellsPerUser 30
PS WSMan:\localhost\Shell> Set-Item .\MaxMemoryPerShellMB 1024
Other PowerCLI commands can also be use to check and configure powershell Memory. Open Powershell CLI. Run below commands.
Get-Item WSMan:\localhost\Shell\MaxMemoryPerShellMB
Set-Item WSMan:\localhost\Shell\MaxMemoryPerShellMB 1024
You can also configure powershell Memory through batch command. Open CMD and run below command to configure it.
winrm.cmd set winrm/config/winrs @{MaxMemoryPerShellMB="1024"}
You can also configure MaxMemoryPerShellMB in multiple machine remotely by using below batch command. Open CMD and run below command to configure it.
for /f %%i in (servers.txt) do (
echo %%i
psexec \\%%i -s winrm.cmd quickconfig -q
psexec \\%%i -s winrm.cmd set winrm/config/winrs @{MaxMemoryPerShellMB="512"}
)