i had similar issue. the script Array was to large and when i open other apps it would eventually kill the PowerShell script. Removed the array and just wrote to a text file with in the loop\iteration. also had a recovery point by doing that.