Query SQL Server using PowerShell

      No Comments on Query SQL Server using PowerShell

Hello!

Here’s a quick script that lets you query an SQL Database, store the results in an array and export to CSV.

The script uses the .NET SQLClient class for connecting to the database and stores the results in a DataTable object. The connection string uses SQL authentication for the user account.

For more info on the custom object used in this script see this post.

Here’s the script:

 

Leave a Reply

Your email address will not be published. Required fields are marked *