Maximum Function Count Powershell Script Running Slow