Selasa, 28 Juni 2016

PowerShell v3 Function Change ProcessPriority

Not sure why I didnt put this one out when I wrote it. I come up with way too many functions...
function Change-ProcessPriority
{
      <#
            .EXAMPLE 1
                  Change-ProcessPriority "High"
                 
            .NOTES
                  Author: Will Steele (wlsteele@gmail.com)
                  Last Modified Date: 06/14/2012
                 
            .PARAMETER Priority
                  A mandatory string indicating the process level to which you want to
                  update a processes priority level.
      #>
           
      param(
            [Parameter(
                  Mandatory = $true
            )]
            [ValidateSet("AboveNormal","BelowNormal","High","Idle","Low","Normal","RealTime")]
            $Priority
      )
     
      if((Get-Process -Id $PID).PriorityClass -eq $Priority)
      {
            Write-Output "The process priority for PID ($PID) is already set to $($Priority).";
      }
      else
      {
            Write-Output "Setting the process priority for PID ($PID) to $($Priority).";
            (Get-Process -Id $PID).PriorityClass = $Priority;
      }
}

lamsim

About lamsim

Author Description here.. Nulla sagittis convallis. Curabitur consequat. Quisque metus enim, venenatis fermentum, mollis in, porta et, nibh. Duis vulputate elit in elit. Mauris dictum libero id justo.

Subscribe to this Blog via Email :