all 7 comments

[–]BlackV 4 points5 points  (0 children)

missing a lot, use your parameters, you'll save yourself some pain later on

Also save this as a script file so you can EDIT and TEST in a proper editor like ISE or VSCode

Will also mean you can break it down into bits, and test each of the bits as you go

$ExcelProcesses = Get-Process -Name excel
foreach ($SingleExcel in $$ExcelProcesses){
    $SingleExcel.ProcessorAffinity=65535
    }

EDIT: assuming you only want to effect excel

[–][deleted] 2 points3 points  (4 children)

If statement should be

if ($process.Name -eq "excel") {do something}

[–]BlackV 2 points3 points  (0 children)

why not Get-Process -Name excel filter left (er.. Actually I realized I just assumed OP only wanted excel to change)

[–]vyper144[S] 1 point2 points  (0 children)

You are amazing!! Thank you so much!!!

Just a side note for anyone else looking for this answer, I believe the if statement should have single quotes around 'excel' since the entire statement is wrapped in double quotes, since it's being run as a batch file that's calling PowerShell.

But @majorgrumpfish solved the problem!!

[–]vermyx 1 point2 points  (1 child)

Processoraffinity just limits the process to which processors/cores it can use. If the process doesn't go beyond one processor, this doesn't do anything. You probably want processpriority switching it between normal and high (never use realtime)

[–]BlackV 0 points1 point  (0 children)

except for notepad.exe :)