PowerShell not enough memory

Today I was running a PowerShell script to remove all records in a SharePoint List, but I got an exception that PowerShell did not have enough memory. By default PowerShell has a memory limit of 1GB

You can check the amount of memory with the following command within a Admin PowerShell window

get-item wsman:localhost\Shell\MaxMemoryPerShellMB

To change this the following command can be ran

set-item wsman:localhost\Shell\MaxMemoryPerShellMB 2048