Introduction to SharePoint PowerShell

Windows PowerShell is a new command-line shell for system administrators. It is a convenient tool which allows administrators to go through system properties and other settings. As SharePoint administrators, we need to care about properties in Farms, site collections, and sites, as well as additional items from anywhere from one to hundreds of servers.

This is the first post in a series on how users can use comdlets in PowerShell to manage Microsoft SharePoint Server 2010. To write an interesting blog, I would like to include more examples rather than just potentially boring text. Also, I will take some pieces of code from my real work to illustrate how powerful PowerShell is.

Let’s begin.

Windows PowerShell is a built-in tool in Windows Sever 2008 which contains hundreds of commands. These single-feature commands which manipulate objects are called cmdlets (pronounced “command-lets”) . All of their names are formatted as a verb and a noun separated a dash (-). For example, get-help and get-command and are the most widely used cmdlets in Power Shell, and we will talking about them later.

In SharePoint 2010, SharePoint 2010 Management Shell extends from PowerShell and adds more than 500 SharePoint related cmdlets.  That is what I call SharePoint PowerShell. We can open it Start -> All Programs -> Microsoft SharePoint 2010 Products -> SharePoint 2010 Management Shell.

The first cmdlet I’d like to introduce is Get-Help. Just type in get-help and you can see the detailed help information. This is particularly useful when combined with another cmdlet name like:

Next, I would like to introduce the Get-Command cmdlet. This cmdlet will provide you all the commands including cmdlets, functions, and aliases. That would be a loooooooong list, so we can use Piping.

Piping is using a (|) symbol to connect two or more commands which means transfer output from the last command to the next one.

How to use this powerful cmdlet? When we get lost in Power Shell, we should use the get-help cmdlet. The next one can provide you lots of examples:

As SharePoint administrators, we need to take care with Object Modules and Web Service. I take Get-SPSite for example. How can I find this cmdlet? Try Get-Help and Get- Command J

First I would like to print out all the site collections in my sever.

 

What can we do with this information? The next powerful cmdlet is Get-Member. It will show you all methods and properties in that cmdlet Piping.

Here is an example:

 

In this example, I get all the site collections in my sever and then use select cmdlet to select URL and Owner properties.

Now let’s end this article with an example to see how we can manipulate these objects only one line script:

 

I hope you liked this article. In the next one, I plan to post an example to solve a real world problem.

 


Muhammad Piracha
wrote
re: Introduction to SharePoint PowerShell
on Wed, Jan 26 2011 12:55 PM

SharePoint Online

The cloud parts are functional components that extend your SharePoint Online environment in Microsoft 365.

Supports Classic and Modern sites for SharePoint Online/Microsoft 365

SharePoint

Top SharePoint Online Products

Experience greater power and savings by bundling our SharePoint apps and cloud parts.


Calendar Plus


Chart Plus


Knowledge Base


Project Management Central


Simple List Search

 

On-Premises Only

These web parts extend SharePoint beyond its out-of-the-box capabilities by tailoring it to your requirements with Bamboo Solution’s growing portfolio of SharePoint Web Parts.

SharePoint 2013, 2016, 2019 – Classic Pages Only

SharePoint

Top On-Premises Only Products

Experience greater power and savings by bundling our SharePoint apps and web parts.


Calendar Plus


Data Viewer


Password Change


Password Expiration


Password Reset

 

Featured Services

SharePoint Health Check

A SharePoint Health Check will identify the causes of issues and risks associated with your specific environment, and is custom tailored to provide you with the best recommendations to optimize your SharePoint environment.

SQL Health Check

Document recommendations relating to performance, stability, availability, or a specific focus you request of your SQL Server database instances.

My SharePointXperts

The truth is that each SharePoint skill may not be a full time job for many organizations, and it is nearly impossible for one person to do everything you need – so augment your team with SharePointXperts; providing the skill sets you need when you need them!