Powershell and Machine.config help
I am very new to powershell and I need a quick hand if at all possible (I am sure this is a common sentence). I am writing a script that optimizes a server to become a webserver, i need to write to the machine.configs using powershell.
I have been trying to figure it out for over a month, lots of googling as well, I cant really find a solution, so I figured to come to the experts. Hopefully i can get good in powershell too and contribute at some point.
I have gotten incredibly far so far and have already done all of the optimizations and most of the powershell but am stuck on 1 part in the script
- I need to get how many cpu cores the machine has
- Once i have how many cores the machine has, i need to write to the machine.config some values.
Under
system.webI need to write
processModel maxWorkerThreads="370" maxIoThreads="370" minWorkerThreads="50" minIoThreads="50"
httpRuntime minFreeThreads="90" minLocalRequestFreeThreads="80"
This would overwrite the already present value listed below
processModel autoConfig="true"
Aside from writing that line there (which I cant figure out how to do), I need to multiply the minfreethreads by the number of CPU cores and write that value in the place of the 90 and the same for minLocalRequestFreeThreads 80
So for example, if the computation sees 2 cores it would write the following lines
processModel maxWorkerThreads="370" maxIoThreads="370" minWorkerThreads="50" minIoThreads="50"
httpRuntime minFreeThreads="180" minLocalRequestFreeThreads="160"
after that, I need to add
system.net
connectionManagement
add address = "*" maxconnection = "200"
/connectionManagement
/system.net
As before, then replace the 200 with the multiplied values of the cpu cores and the 200. I hope that’s not too much to ask, I don’t know how to write to xml files, and then also multiply the cores and take that value and add it there?
so it would like this
system.net
connectionManagement
add address = "*" maxconnection = "400"
/connectionManagement
/system.net
Can anyone give me a hand?