

# now get all running instances of Excel and associate them with a random subset of the available processors (random so users are evenly spread to limit competition), ignoring the first (cpu 0) so that this can be dedicated to other tasks (in case all users are hammering excel)įoreach ($excel in (Get-Process 'CCR') -IncludeUserName)) ' -f (Get-Date).ToUniversalTime()) Set $($excel.Name) for $($excel. allow users to use 1/3rd the available processors (rounded up) $procsPerUser = ::Ceiling($noProcessors / 3) # i.e. this signfies that all processors are assigned to a process $maxAffinity = ::Pow(2, $noProcessors) - 1 # i.e. $noProcessors = (Get-WmiObject -class 'Win32_Processor' -Namespace 'root\cimv2').NumberOfLogicalProcessors It never assigns 1 of the CPUs, ensuring that's free for other tasks. The modern multi-core processors are designed to perfectly work with most operating systems. In this case it allocates a random subset of the logical processors to each. Processor Affinity was first introduced in Windows 7. This detects any tasks with a given process name, then updates their processor affinity. Here's a dirty fix where you have a powershell script running in an elevated session in the background (you could remove the loop and set it as a scheduled task).
