Changed getText to output as write-output to make it work better when assigned to a variable