How do find out what chews up host memory?


I have super simple script which causes Powershell to kill itself in remote session becouse of memory limit. After about 15 iterations host memory will be at 1 GB,

Import-Module Webadministration
for ($index = 0; $index -lt 50; $index++) {Get-ChildItem IIS:\AppPools | select -First 1 | set-itemproperty  -name enable32bitapponwin64 -value $false }


For me it looks like you are trying to set same setting on same AppPool for 50 times. Is that the intention?

This is because you run your scriptblock 50 times, but in scriptbloc value is always the same (no reference to $index).


No, this is for illustration purposes only. I have to modify 5 different settings within each application pool and if I have more then 3 application pools on my machine then Powershell will stop working because of memory leak.

Just a guess:
Can it be that changes are executed too fast? Try adding sleep in between commands.