Skip to content

Instantly share code, notes, and snippets.

@Waester
Created March 18, 2018 17:33
Show Gist options
  • Save Waester/e62bce38c73dacad0eeaeb38d16d82f9 to your computer and use it in GitHub Desktop.
Save Waester/e62bce38c73dacad0eeaeb38d16d82f9 to your computer and use it in GitHub Desktop.
# 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