Summary

In this chapter, we looked at different ways of sending queries and commands to SQL Server using PowerShell. We saw that, in addition to using the cmdlets Invoke-Sqlcmd and Invoke-Expression, we can also utilize ADO.NET and SMO. We also learned to that although in most cases we can use PowerShell to query SQL Server, we have to consider if there are better tools to assist us in accomplishing our task.

In the next chapter, we will look at tasks that help monitor and automate SQL Server, and see how these are accomplished using PowerShell.

Get PowerShell for SQL Server Essentials now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.