Skip to content

Instantly share code, notes, and snippets.

@Katzenwerfer
Created August 4, 2022 21:31
Show Gist options
  • Save Katzenwerfer/ef725aa5aaed126615766d3ce0770ed6 to your computer and use it in GitHub Desktop.
Save Katzenwerfer/ef725aa5aaed126615766d3ce0770ed6 to your computer and use it in GitHub Desktop.
Script to persistently set the priority of an application that matches the specified name
Set-PSDebug -Trace 0
$process = Get-Process -Id $pid
$process.PriorityClass = 'Idle'
$Application = "" # Name of the application (Get-Process)
$Priority = "" # Priority (Idle|BelowNormal|Normal|AboveNormal|High|RealTime)
function Set-Priority {
$process = Get-Process -Name "$Application"
$process.PriorityClass = "$Priority"
}
function Find-Process {
try {
Get-Process -Name "$Application" -ErrorAction "Stop"
Set-Priority
} catch [Microsoft.PowerShell.Commands.ProcessCommandException] {
#
} catch {
#
}
}
for () {
Find-Process
Start-Sleep -Seconds 1
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment