Created
March 18, 2018 17:33
-
-
Save Waester/e62bce38c73dacad0eeaeb38d16d82f9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://blogs.msdn.microsoft.com/santhoshonline/2011/11/24/how-to-launch-a-process-with-cpu-affinity-set/ | |
Set-StrictMode -Version Latest | |
while ($true) { | |
Start-Sleep -Seconds 10 | |
$ApplicationList = Import-Csv affinity.csv | |
$ProcessList = Get-Process | |
foreach ($Process in $ProcessList) { | |
foreach ($Application in $ApplicationList) { | |
if ($Process.ProcessName -eq $Application.Name) { | |
if ($Process.ProcessorAffinity -ne [int]$Application.Affinity) { | |
$Process.ProcessorAffinity = [int]$Application.Affinity | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment