Powershell for SQL

SQL with its own Powershell?

SQL Server 2008 and powershell are strongly integrated. In fact, SQL Server 2008 comes with its own Powershell. Microsoft SQL Server Powershell also known as SQLPS is basically a custom shell built to be used just for SQL Server. SQLPS comes preconfigured with all SQL Server extensions.

Technically speaking SQLPS is a mini-custom-powershell which has multiple Snappins created for SQL Server with its own custom cmdlets (pronounced as command-lets). SQLPS is a great tool to Administer, Monitor or Automate your SQL tasks provided you don’t go beyond SQL, means you can’t add other snappins to SQLPS. This makes it a “CLOSED” shell.

SQLPS uses two Snappins SqlServerCmdletSnapin100 & SqlServerProviderSnapin100. We can use Get-PSSnapins cmdlet to see all loaded\configured snapppins.

If you’ve any exposure to Linux or command prompt, Learning Powershell is very easy. Microsoft did a fabulous job and tried hard to provide the same look and feel + your (few) favorite commands are also compatible in powershell.

Yes, that means if you are coming from Windows background and love to use command prompt you can adopt powershell and start using just like another command prompt with commands like dir, cd and the same is true for Linux experts since powershell supports ls, man etc. Microsoft did this using Aliases Dir, ls are Alias for Get-ChildItem.

Thanks,
Sarabpreet Singh Anand