Board logo

标题: [转载代码] [PowerShell每日技巧]降低PowerShell进程的优先级(20140102) [打印本页]

作者: DAIC    时间: 2014-1-4 11:43     标题: [PowerShell每日技巧]降低PowerShell进程的优先级(20140102)

When you run a PowerShell task, by default it has normal priority, and if the things your script does are CPU intensive, the overall performance of your machine may be affected.

To prevent this, you can assign your PowerShell process a lower priority and have it run only when CPU load allows. This will ensure that your PowerShell task won't degrade performance of other tasks.

This sample sets the priority to "below normal". You can also set it to "Idle" in which case your PowerShell script would only run when the machine has nothing else to do:

$process = Get-Process -Id $pid
$process.PriorityClass = 'BelowNormal'

http://powershell.com/cs/blogs/tips/archive/2014/01/02/lowering-powershell-process-priority.aspx




欢迎光临 批处理之家 (http://bbs.bathome.net/) Powered by Discuz! 7.2