A heavy Powershell script uses a lot of ram to proceed. There are many ways to avoid that, and also avoid crashes of the server launching that. The easiest way is to use multithreads with job.
Using jobs will open a new thread into your server/remote server to execute a part of the script. Jobs also can be called to work at the same time, reducing the global execution time of the script.
Here below a small script to introduce you using jobs :