Powershell Variable Scope In Function Sql Syntax