-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSet-ProcessPriority.ps1
More file actions
45 lines (42 loc) · 1.07 KB
/
Copy pathSet-ProcessPriority.ps1
File metadata and controls
45 lines (42 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<#
.SYNOPSIS
Setzt Prozesspriorität per Name oder PID
Um es zu kompilieren, nutze PS2EXE:
Install-Module PS2EXE -Scope CurrentUser
Invoke-PS2EXE -inputFile "G:\AVERP\Set-ProcPriority.ps1" -outputFile "G:\AVERP\Set-ProcPriority.exe" -noConsole
\\myserver\myshare\Set-ProcPriority.exe -Name MYPROCESS -Priority AboveNormal
#>
param(
[string]$Name,
[int]$ProcId,
[ValidateSet('Normal', 'BelowNormal', 'AboveNormal', 'High')]
[string]$Priority = 'AboveNormal'
)
if ($ProcId) {
$procs = Get-Process -Id $ProcId -ErrorAction SilentlyContinue
}
elseif ($Name) {
$procs = Get-Process -Name $Name -ErrorAction SilentlyContinue
}
else {
return
}
foreach ($p in $procs) {
try {
$p.PriorityClass = $Priority
# [PSCustomObject]@{
# PID = $p.Id
# Name = $p.ProcessName
# Priority = $p.PriorityClass
# Success = $true
# }
}
catch {
# [PSCustomObject]@{
# PID = $p.Id
# Name = $p.ProcessName
# Priority = $Priority
# Success = $false
# }
}
}