I want to use PowerShell to assign a process to only the performance cores on a hybrid CPU. I can currently set affinity manually, for example with `$Process = Get-Process myexename` followed by `$Process.ProcessorAffinity = 0x00000000000FFC00`, which selects logical processors 10 through 19. Is there a way to enumerate the logical processors, determine whether each one is an efficiency core or performance core, and then generate a hexadecimal affinity mask containing only the performance cores?
3 Answers
For building the mask once you know which logical processors to include, shift a single bit for each processor and combine the results with bitwise OR. For example, processor `n` contributes `1 -shl n`; combining the selected values produces the affinity mask. This is equivalent to manually specifying a range such as processors 10 through 19, which results in `0xFFC00`.
If you already have a list or range of processor numbers, you can generate the mask directly. Convert every processor number into its bit value with `1 -shl $_`, then combine those values using `-bor`. For processors 10 through 19, the merged result is `0xFFC00`, matching the affinity value in the example. A helper function can format the individual flags and merged value for PowerShell 5 or PowerShell 7.
Windows exposes this through the `GetSystemCpuSetInformation` API in `kernel32.dll`. The returned CPU-set information includes an `EfficiencyClass` value: `0` identifies efficiency cores and `1` identifies performance cores. In PowerShell, you can call that API, filter for entries where `EfficiencyClass -eq 1`, and use their logical processor indexes to construct the affinity mask. This approach works well for hybrid CPUs because it discovers the layout instead of assuming that a fixed range contains the performance cores.

Exactly—each logical processor corresponds to one bit. The important part is identifying the processor indexes first; after that, `-shl` and `-bor` can assemble the final mask.