This module provides Cmdlets that let you work with Microsoft SQL Server database (regular and LocalDB) by utilising System.Data.SqlClient (instead of relying on the buggy ‘SqlServerCmdletSnapin100’ snapin and its ‘Invoke-Sqlcmd’ implementation. You can set a ‘DefaultPrefix’ or an alias to call it the same as the Microsoft SQL Server supplied ‘Invoke-Sqlcmd’.
Furthermore you can work with LocalDB instances (as used by Visual Studio and others) by specifying a connection string such as:
‘Data Source=(LocalDB)\v11.0;AttachDbFilename=”C:\VS\prj1\bin\Data\ApplicationDatabase.mdf”;IntegratedSecurity=True;Connect Timeout=30’
Again this module is published under the Apache 2.0 license.
You can download the module on GitHub at https://github.com/dfch/biz.dfch.PS.System.Data or you can get it on NuGet with ‘Install-Package biz.dfch.PS.System.Data’ (https://www.nuget.org/packages/biz.dfch.PS.System.Data/)
CommandType Name ModuleName ----------- ---- ---------- Function Invoke-SystemDataSqlCmd biz.dfch.PS.System.Data
Note:
* This module updates and enhances the previous implementation of my ‘Invoke-SqlCmd‘.
* For a description on ConnectionStrings and SqlConnectionStringBuilder with LocaolDB see:
SqlClient Support for LocalDB
http://msdn.microsoft.com/en-us/library/hh309441%28v=vs.110%29.aspx
* For a description on PSBase which is needed to work with the ConnectionStringBuilder see:
What’s up with PSBASE, PSEXTENDED, PSADAPTED, and PSOBJECT?
http://blogs.msdn.com/b/powershell/archive/2006/11/24/what-s-up-with-psbase-psextended-psadapted-and-psobject.aspx
1 Comment »