Chapter 16. Windows PowerShell and SQL Server
Windows PowerShell was introduced in 2007, and it has since become a standard platform for administrative automation across Microsoft business and server products. It’s a command-line shell, and product teams (like SQL Server’s team) extend the shell so it can help manage their products. In this chapter, we’ll look at how to use PowerShell with SQL Server.
Windows PowerShell is a command-line shell, not unlike Unix-style shells like Bash or the old Windows Command Prompt (Cmd.exe). What’s different about PowerShell is that it’s a modern shell, designed around modern needs and with the Windows OS in mind. The shell itself contains minimal functionality; feature and product teams write modules (or snap-ins) that give the shell additional capabilities. For example, the SQL Server team created a module that lets the shell connect to, and manage, SQL Server. It’s important to keep in mind that the ability to manage a product by using PowerShell is dependent upon the specific product version providing that module. SQL Server 2012 provided SQL Server’s first fully functional module, making it the oldest version of SQL Server that can be extensively managed by using PowerShell. SQL Server 2008 R2 shipped with a less-complete snap-in for PowerShell.