Change PowerShell Script Process Priority

Change PowerShell Script Process Priority


If you've got an intensive PowerShell script, you may find that running it can slow your system to a crawl - as it is given "default" process priority and has to compete with other system applications. Likewise, you may have an important script you wish to run with priority over other system tasks.

You can change the process priority of your script by adding the following code to the beginning, where PRIORITYLEVEL is equal to one of the following options:
  • Idle
  • BelowNormal
  • Normal
  • AboveNormal
  • High
  • RealTime
Code:
$process = Get-Process -Id $pid
$process.PriorityClass = 'PRIORITYLEVEL'
I run several scripts using the "idle" priority option, as they are CPU intensive tasks that can take as long as required to finish. This frees up system resources for running more important tasks.
Reactions: Regedit32

Author
Ian
Views
60
First release
Last update

More resources from Ian

Top