foreach ($f in Get-ChildItem -path "C:\Users\bi-info\Desktop\SQLQuery\" -Filter *.sql )
{
write-host $f.fullname
$out = "C:\Users\bi-info\Desktop\SQLQuery\Output.txt" ;
invoke-sqlcmd -InputFile $f.fullname -Database "DBNAME" -ServerInstance "SERVERNAME" | format-table | out-file -filePath $out
}