Monthly Archives: July 2014

Yet Another Invoke SQL PowerShell Script

Tags :

Category : Windows PowerShell

A few weeks ago, I uploaded my PowerShell function Invoke-SQL to the Microsoft TechNet Gallery and I forgot to mention it here.

Invoke-SQL is designed to issue any valid SQL command text against an ODBC database connection. The function either accepts an existing OdbcConnection object or a connection string in order to create a connection on the fly. By default the function returns $true if the execution of the given SQL statement didn’t fail. With the PassThru switch the function loads the results into a DataTable object and returns it for further processing. Invoke-SQL returns nothing on error opening the ODBC connection or executing the SQL command text.