Set Processor Affinity with Powershell

Hey all I know its been far to long since my last post. I have been doing a lot of great things with powershell and I am going to start sharing them as they come up. Here was a helpful one this morning…

So the Backup Server is going nuts with these storageservice.exe processes consuming 100% of the CPU. It makes it very hard to troubleshoot when the server doesn’t have enough CPU to let the OS run.


Below is a script I just created that takes all of them and sets them to only use cores 1 – 4 (basically only allowing it 50% of the total CPU power.

# Set Processor Affinity by adding the number together. For cores 1 – 4 its 15 for example.
# 1 (CPU 1)
# 2 (CPU 2)
# 4 (CPU 3)
# 8 (CPU 4)
# 16 (CPU 5)
# 32 (CPU 6)
# 64 (CPU 7)
#128 (CPU 8 )

$instances = Get-Process storageservice
foreach ($i in $instances) {

Ah much better, now time to figure out why its going nuts….


2 Replies to “Set Processor Affinity with Powershell”

    1. Great question, I dont have a system to test that with but I would think that it stacks them so if you have dual quad core it would just be CPU’s 0-7.

Leave a Reply

Your email address will not be published. Required fields are marked *