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:
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