Optimizing HW and OS for powershell performance

Hello.

I was looking for some articles about optimizing HW and OS for PowerShell performance, I always end up with articles about optimizing PowerShell code. I do not argue with the need of optimizing the code. But is there a way how to also optimize HW and OS (system variables?) to make PowerShell run as optimized as possible? An example:

I am processing IIS logs and I need to do combination without repetition. I tried to simplify the code to keep the idea without sending unnecessary code ($collection1 and $collection2 are the same):

      foreach ($collrow1 in $collection1) {
        $ip1 = $collrow1.cip
        $collection2.RemoveAt(0)
        foreach ($collrow2 in $collection2) {
        $ip2 = $collrow2.cip
        if ($ip1 -eq $ip2) {
            ....
        }
        }
       }
I tried using workflow and foreach -paralel
      foreach ($collrow1 in $collection1) {
        $ip1 = $collrow1.cip
        $collection2.RemoveAt(0)
        foreach -parallel ($collrow2 in $collection2) {
        $ip2 = $collrow2.cip
        if ($ip1 -eq $ip2) {
            ....
        }
        }
       }
The results were tragic. The output was the same = both versions produced same result, same data. But that "optimized" version ran 10 times longer. It actually makes sense. The system was Windows Server 2019 running in Hyper-V with single vCPU. I just made things worse. I am going to add vCPU so that system runs 16 vCPU. But I have no idea if it helps, or it is too much and useless. Does PowerShell really use it?

I am also trying to chew this article:

https://adamtheautomator.com/powershell-multithreading/

It goes slowly because I am not a programmer.

But my question is: I have Windows Server 2019 with 16CPU, 32GB RAM, almost no applications running. Can I do anything with the OS or HW to make PowerShell run faster?

Thank you

Honza

If I understand correctly, you want to combine IIS logs and search the logs for a string? Give an example of what you want the output to look like.

No, I just need to know if there are any recommendations regarding HW and OS. Something like:
Use as much CPU as possible or do not use more than X cores, because …

Use as much RAM as possible or do not use more than X because …

Set this ENV variable to allow best PowerShell performance …

Does anything like this exist?

Not sure there are performance setting for Powershell per se and typically performance is totally a ‘it depends’. If we wanted to multi-threading, we would test and see how many threads a system can handle, but this would depend on what you’re doing. If you were performing multiple transactions against something like Exchange or API’s, you’re going to hit a login limit or throttling. Outside of that, having the latest versions typically have security and performance upgrades. My .02