Press "Enter" to skip to content

Invoke-SqlCmd

Mike Fal defends Invoke-SqlCmd’s honor:

Why do people gripe so much about Invoke-SqlCmd then? Well, to understand this is to understand the history of SQLPS. For a long while, the SQL Server module for PowerShell was klunky and buggy. There were a lot of challenges with loading it and using it, such that many scripters decided to throw it out and write their own functions. In many cases, PowerShell folks would skip Invoke-SqlCmd not because it was bad, but because it came packaged with the rest of SQLPS and they wanted to avoid the entire module.

Now that the SQL Tools team has been reworking the module as SqlServer, this has become less of a concern. The module is less of a burden to load and the other components do not get in the way. There are also improvements and updates to the code to make it work better and serve more needs.

MikeĀ makes good points, like how you can pretty much guarantee that Invoke-SqlCmd will be available, whereas you can’t always guarantee that third-party libraries (even if better) will beĀ available on all systems at all times.