PowerShell and the Not enough storage is available to complete this operation error

Recently while running a PowerShell script, I started having some problems that had never happened before. I hadn’t made any changes to the script, but the section of the script that remotes into a SharePoint server and updates a list quit working for some reason. The script was just hanging there, and would eventually time out on that section and move on. Luckily, PowerShell threw an error at me to give me some idea of what was happening.

Processing data for a remote command failed with the following error message: Not enough storage is available to complete this operation. For more information, see the about_Remote_Troubleshooting Help topic.

“Not enough storage is available”? The first thing my brain did was flashback to NT4 Service Pack 3. Do I need to set the IRPStackSize registry key? Probably not, and I was really surprised I remembered that issue, it’s been a decade or so.

After some Googling with Bing, I discovered that by default, WSMan allocates only 150M of memory to each remote shell. You can verify that by running this one-liner:

(Get-Item WSMan:localhostShellMaxMemoryPerShellMB).Value

That should return 150 if you haven’t made any modifications. My script wasn’t putting that much data into SharePoint, but I figured this looked like a likely culprit, and hey, memory is cheap these days. So I bumped that 150M up to 1G.

Set-Item WSMan:localhostShellMaxMemoryPerShellMB -Value 1024

After changing that setting and running the script again… Bingo! The SharePoint data was successfully input and the script was fully functional again. I’m not sure what might have caused that to happen as nothing had changed in the script or on the server, but as long as it’s working, I’m happy.

4 thoughts on “PowerShell and the Not enough storage is available to complete this operation error

  1. Excellent tip, thanks so much! One little modification though…you forgot some backslashes in the above commands:

    (Get-Item WSMan:localhostShellMaxMemoryPerShellMB).Value
    Set-Item WSMan:localhostShellMaxMemoryPerShellMB -Value 1024

    • Well, looks like your site filters out backslashes. Commands should look like this (replace the [bs] with an actual backslash):

      (Get-Item WSMan:localhost[bs]Shell[bs]MaxMemoryPerShellMB).Value
      Set-Item WSMan:localhost[bs]Shell[bs]MaxMemoryPerShellMB -Value 1024

  2. Correct Commands

    Get-Item WSMan:localhostShellMaxMemoryPerShellMB
    Set-Item WSMan:localhostShellMaxMemoryPerShellMB 2048 -Force

  3. You are BRILLIANT…
    This has been driving me nuts for the longest time.

    I created a script to remotely create a WIM file of an online PC’s C: drive while in use using VSS as a sort of modernized “cloning” solution that could all be operated through an SCCM task sequence, allowing new PC’s to be built as clones of existing one’s while the old PC’s they were replacing were online and still in use by users.

    The original script was in batch and using PsExec for the remote connection, but I eventually adapted it all to PowerShell and WinRM and the weird thing was, it was working fine at first, but one day, I started seeing various machines throw the “not enough storage” error with increasing frequency, and all at the same place! I kept messing with IRPStackSize because it was all I could find and I had no success; I’d given up

    The reason it’s an issue in my case is because the script is sending out a TON of output for each of the files on the volume that it’s parsing back to the client starting the remote session and that was triggering the allotted 150 MB for remote sessions to be exceeded and terminate. I applied your fix to the script to always check/set this value and it did the trick!

    Keep in mind to anyone else reading this, newer versions of PowerShell/WMF have their MaxMemoryPerShellMB value already set higher, to 2048 MB in most cases so this is probably a safe value to set it to. PowerShell/WMF 2.0 or lower on Windows 7 will have this 150 MB limit though.

    And, as mentioned above, the Get and Set-Item commands in the article contain WSMan PATHS and DO need backslashes in them; this site is filtering those characters out though so they aren’t visible. Replacing underscores with backslashes, you should use the following:


    Use dir WSMAN: to see the hierarchy for yourself if you’re still confused

Leave a Reply