Powershell Function Returning Within A Loop