Learn more about SQL Server tools

mssqltips logo

Tutorials          DBA          Dev          BI          Career          Categories          Webcasts          Scripts          Today's Tip          Join

Tutorials      DBA      Dev      BI      Categories      Webcasts

DBA    Dev    BI    Categories


Introduction to Windows Powershell for SharePoint 2010

By:   |   Updated: 2010-12-23   |   Comments   |   Related: > Sharepoint


Lately, there has been growing demand for information about Windows Powershell and SharePoint. The reason is because it is so powerful and easy to use. The built-in commands can handle administrative tasks that are just not possible through Central Administration. Although, Powershell can be used for different technologies we will concentrate on the usage of Windows Powershell for SharePoint starting with a brief introduction.


If you don’t have Powershell installed you can get it from here. If you are using SharePoint 2010 then it’s a pre-requisite to have this; therefore it will be installed during the installation.

Open Powershell by finding it in your Programs or run "powershell.exe". Once loaded you will see a basic Powershell command prompt (see image below).

powershell window

To get a list of all the built-in commands (cmdlets) in Powerhsell just type get-command | format-list. (Note: Powerhsell is not case sensitive).

get-command | format-list

Notice there is a symbol in the command with a vertical bar "|", this is called a Pipe. The Pipe is used to separate different parts of the command. The different parts can be used to include options, formatting or a way to pass variables.

Some examples

Let’s say you want to list all of the services on your system. This is the simple Powershell command to do this.


Let’s say you want to list all of the services on your system, sort the list by the status of the service and return the results in a table format . This is the Powershell command to do this.

get-service | sort-object status | format-table

Passing variables

Let’s say you want to store the data of all the services in variable called "svs".

Variables always start with a $ letting the shell know that it is a variable. So, the commands will be as follows:


The first line will store all the running processes in variable "svs". The second line will return all of the data that was stored in the variable "svs".


These are just a few examples to get you started with Powershell. You can check the links under the Next Steps section to learn more about Powershell.

Next Steps
  • Did you know you can install SharePoint 2010 with the help of PowerShell? Check out this article here to get details about how this can be done.
  • Microsoft has also published Powershell commands for SharePoint click here.
  • If you want to learn Powershell click here.
  • If you want to check the Powershell online manual click here.
  • Here is a Powershell webcast.

Last Updated: 2010-12-23

get scripts

next tip button

About the author
MSSQLTips author Amarprit Jaspal Amarprit Jaspal

View all my tips

Post a comment or let the author know this tip helped.

All comments are reviewed, so stay on subject or we may delete your comment. Note: your email address is not published. Required fields are marked with an asterisk (*).

*Name    *Email    Email me updates 

Signup for our newsletter
 I agree by submitting my data to receive communications, account updates and/or special offers about SQL Server from MSSQLTips and/or its Sponsors. I have read the privacy statement and understand I may unsubscribe at any time.


Learn more about SQL Server tools