August 31, 2010 10:45 AM

Learn How to Manage SharePoint with PowerShell

With practice, PowerShell will become your best friend
SharePoint Pro
InstantDoc ID #125513
Rating: (3)

Sidebars:

The SharePoint Management Shell

What Is an Object?

We all have a pair of jeans that fits just right. We’ve had them for years and they hug us in all the right spots. They might not be the best looking, and they might have a few holes in them, but they're comfortable and we like them. For SharePoint 2007 admins, STSADM was like that pair of jeans.

Sure, it was a bit persnickety and somewhat limited in its usage. But we liked it and it was all ours. After using STSADM with SharePoint 2007, and maybe even SharePoint 2003, we were comfortable with STSADM and finally able to work around its idiosyncrasies to get things done.

Then SharePoint 2010 came along and everything changed. SharePoint 2010 gives up our beloved STSADM for PowerShell. That pair of jeans we’ve spent years and years getting just the way we want isn't any good any more.

But don’t fret fellow SharePoint admins. PowerShell does more than STSADM and, in general, does everything faster. We can eat all we want and our new jeans will still fit. Not only will these jeans fit, but they have more pockets and they make us look even better than our old jeans did.

In this article, I'll show you how to start using PowerShell to administer SharePoint 2010. You'll learn how to get around in PowerShell and what to do when you’re completely lost. And I'll show you how to get PowerShell to do your SharePoint bidding for you. You won’t have a Ph.D. in PowerShell by the end of this article, but you’ll have a solid GED you can be proud of. 

Where to Begin

Let’s put this out in the open right up front; PowerShell is scary. STSADM might not have had the most friendly interface, but if you screwed up, it spewed its usage out to the screen in an almost condescending manner, as if to say “Bzzzt! Try again!”

While this could be frustrating at times, it was helpful. When STSADM did its dump to the screen, it was all SharePoint-related junk. You had a good chance of being able to muddle through and figure something out.

PowerShell is not nearly so forgiving. And how do you even know where to start? To make sure you get PowerShell with all the SharePoint goodness baked in, start it with the SharePoint Management Shell shortcut in the Start menu. If you try to manage SharePoint in any other PowerShell console, you’re going to find it even less welcoming than usual.

When you fire up the SharePoint Management Shell it doesn’t offer any advice; it just blindly stares back at you, blinking, expecting you to do something. If you’re not familiar with PowerShell, this can be quite daunting. Where do you start?

The good news is that you don’t need anything fancy to get started. Help is as easy to find as just typing "help." When you type help in any PowerShell prompt, you’ll get a screen full of really useful help. If you remember nothing from this article, remember to type help when you need help in PowerShell. In return, you’ll get a screen like Figure 1 shows.

The help screen offers a lot to digest, and it probably won’t all make sense right away. The two key things to take away from this help screen are using Get-Help followed by a cmdlet name to see how to use the cmdlet, and using Get-Command to help you find commands.

Both of these help commands will serve you well as you make your way through the PowerShell jungle. You might have noticed a pattern in the PowerShell cmdlets Get-Help and Get-Command: they’re both in the form of verb dash noun. In the preceding cases, Get is the verb and Help and Command are the nouns. Note also that the nouns are singular. This makes discovering cmdlets easy, once you know that all the nouns in the SharePoint PowerShell cmdlets start with SP.

A command like Get-Command –Noun SP* will return all the cmdlets in PowerShell that deal with SharePoint. This gives you a great jumping off point. As you scroll through the 500+ results, you see not only each SharePoint-related PowerShell cmdlet, you also start to see the patterns associated with them. You'll see nouns like SPWebApplication, SPWeb, SPSite, and SPUser. It might be handy to make a searchable list of these cmdlets.

The following command will take the output of the Get-Command statement and save it to a text file called sharepoint-cmdlets.txt. Then you can use something as simple as Notepad to open the file and search for SPSite, SPWeb, or whatever term you're interested in.

 

Get-Command -Noun SP* | Select Name | Out-File sharepoint-cmdlets.txt

 

Related Content:

ARTICLE TOOLS

   
Comments
  • Van De Sande
    1 year ago
    Jan 03, 2011

    Thanks for the article! Just learning there was such a thing as Get-Member made my life so much easier.

You must log on before posting a comment.

Are you a new visitor? Register Here
   
   

SharePoint News and Products

Let SharePoint Be SharePoint: Making Social Collaboration Secure

Hesitant about unleashing SharePoint's social features? SharePoint security vendors aim to help....

Dan Holme's Viewpoint on SharePoint Blog

Microsoft SkyDrive Updates in the News

Microsoft's cloud storage, sharing, and collaboration platform for Windows Live is updated,...