I’ve found that the Powershell Window performace is limited unless you make some changes.
Below are some quick things you can do to increase the performance and hopefully reduce the time of your script execution.
– This command will check and set the Max Memory that each Powershell session can use.
Default is 150MB:
Set-item WSMan:\localhost\Shell\MaxMemoryPerShellMB 1024 -Force
– This command, added to your script, will run garbage colection and free up some RAM.
– It was found that Windows Tasks will launch your Powershell scripts at “Below Normal” CPU priority.
This is how you can fix that issue. Its a pain but VERY worth it if you use Windows Tasks to launch your scripts.
Step1 – Export your Task to an XML file.
– schtasks /query /tn “\MyTask” /xml > “c:\temp\MyTask.xml”
Step2 – Edit the XML file (Notepad works) and change this part “<Priority>4</Priority>”
– You should see that the orginal is set to a value of 7. Setting it to 4 makes a world of difference.
Step3 – Import the XML back into the Tasks window.
– Within Task Scheduler, right click the folder you want the task to live and select “Import Task.”
– Browse to your file, Click Open, edit your task as needed and save it