SQLPS - Powershell in SQL Server

Those who are using SQL Server must have idea of Powershell eventhough they dont have used it.
Its a nice utility and sometimes makes work more easy then routine coding.
Here today first we weill get basic idea on how to use it.
Before SQL Server 2012 it was a sepereate exe SQLPS.exe, but 2012 onwards MS has added it as a seperate module for powershell. So eventhough SQLPS is available, it will be deprecated in future.



Now lets see how to use Powershell and add SQLPS modules in it.

1. Open Powerhsell
Open windows poewrshell from start menu.





2. Now we need to check either SQLPS module is loaded or not.
Run this command

Get-Module -ListAvailable

As we can see SQLPS is already loaded.
I am using SQL 2014 and it by default loaded in windows powershell.


3.Now we will connect to SQLPS
Run this command
SQLPS






4.Now we will get list of cmdlets available for SQL Server
Run this command
Get-Command -Commandtype cmdlet -Module SQLPS
It will list all available cmdlet for SQL Server



No comments:

Post a Comment

Popular Posts