$sql = "

SELECT cd as [SchoolCode],
nm as [SchoolName]
FROM [loc]
"
$filename = "c:\temp\This.txt"

Invoke-SqlCmd –ServerInstance "SQLSERVER" –Database "DST16000AeriesDemo" -Username "test" -Password "test" -Query $sql | Export-Csv -NoType $filename