The below is an example PowerShell script to connect to a Microsoft SQL Database and dump the results of a query into a CSV file.

You will need to change the variables at the top along with the column names against the line starting “$DataSet.Tables[0] | select”