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.

Related Posts

String Formatting With Powershell

Thomas Raynor provides a quick tip for string formatting in Powershell: And, for some reason, instead of the default output which is formatted like a table, I want output presented like this. 1 2 3 .ps1     file extension: 11 .xlsx    file extension: 3 .dll     file extension: 1 This is a silly example, but notice that even […]

Read More

What’s In Your Powershell Profile?

Shane O’Neill wants to know what’s in your Powershell profile: This brings me back to the main point. My profile does 3 things Changes the default colour of error and warning messages, Sets an alias for notepad to “n” since I use it so much Set-Alias -Name n -Value notepad , and loads up the dbatools prompt […]

Read More

Categories

March 2017
MTWTFSS
« Feb Apr »
 12345
6789101112
13141516171819
20212223242526
2728293031