Practical Windows PowerShell for SharePoint 2010

I’ve seen a lot of confusion with various people’s approaches to Windows PowerShell.  Customers are First there’s the aversion to Windows PowerShell as a "language” and something that will take time, a class, and tons of ramp up.  Many decide to put it off until they are forced to learn it for something.  Let me give you some practical guidance so you can start to approach it and understand it’s not all that bad…  As you work your way through this blog, you’ll also find resources from other bloggers that will help you consume Windows PowerShell without getting overloaded.  The key to remember is take as much as you want, but eat only as much as you take… or something like that.  Just don’t over do it, that’s what I’m trying to say.  There’s a lot of goodness here in Windows PowerShell, don’t be overwhelmed.

The way I see it there are a Good 3 levels of SharePoint & Windows PowerShell skills that need to be approached in different ways.  I’ve broken it down so it can be more easily digested.


Level 1 – The Beginner/Newbie Using Cmdlets

Newbies to SharePoint 2010 who are trying to learn how to use Windows PowerShell with SharePoint should NOT just go out and buy a book on Windows PowerShell or simply take a class.  At this level the biggest bang for the buck is learning the SharePoint specific cmdlets.  There are more than 500 cmdlets and by simply gaining control of learning how to get into the help and being able to find examples and successfully adding parameters is mastery at this level.  First you need to be able to do pretty much most of what you can do in STSADM then work your way up to running things you don’t have available.

Pretty much most of what you’ll do at this level you can find in TechNet in the SharePoint commandlet sections.  When you start finding mastery over the commandlets and can find your way around, then you need to start looking at the next level.  The things to watch out for are syntax and making sure you’re testing things out first.

Most of what you’re focusing on at this level should be pretty specific to SharePoint cmdlets while anything you learn about Windows PowerShell will obviously make life easier and help you in the next level.

SharePoint Powershell Commands and Cmdlet References

Resource Articles and Blogs for more information at this level:



TechNet: Spend 30 minutes with Todd Klindt in this getting started video to see how the SharePoint Commandlets can make your life easier. Also dig into Todd’s blog: Using PowerShell to set up a test environment

Level 2 – Advanced – Scripter and Parser

Now that you’re comfortable running the commandlets you can now start to approach learning how to grab a list of sites or webs and those as variables into a second commandlet.  You can Also pass an XML list of sites or webs and set configurations or pull configuration.  My recommendation would be to be working in your test farm, and use this to first try to read data for reporting purposes and then work your way up to changing configuration such as read locking sites and then trying to change quotas, something that was a pain that has become more simple.

You’ll find working with the developer dashboard in Windows PowerShell isn’t just simply turning it on off or on demand, you now have a lot more control over it.  I’d encourage you at this level to start looking at the custom commandlets that people have built, and look at scheduling tasks and using Windows PowerShell to script the creation of a farm.  Look at THE Script To Retrieve Effective SharePoint Permissions Has Arrived for example.  Writing and/or using scripts can definitely make your life easier in cases of disaster recovery for all sized farms, but also for making your job more automated.  If you can run a script that would take hours to do manually, now you’re seeing the power.  The things to watch for are performance.

You can definitely benefit from reading blogs and others scripts at this level.  You can also find some awesome scripts put together to configure farms, install and customize services.  Look at the scripts that Zach Rosenfield has PM’ed like SPModule for scripting deployment of 2010 farms.  The books that are being written on SharePoint and Windows PowerShell will definitely help you get better.  All these skills you’re learning here will benefit you on scripting for Exchange and visa versa.  That Windows PowerShell class you’ve been eyeing up can make you better at this level.

When you start working with multiple farms, the Windows PowerShell sometimes is where you have to dive to really get into the guts and configuration of things like configuring service apps.  Even as something as simple as the import after doing an export requires powershell.


General Windows PowerShell Resources:

Level 3 – Expert – The Commandlet Creator

I think most who think of SharePoint Windows PowerShell think of this level.  They think “Woah, I have access to the Object Model, that’s crazy!”  At this level that’s the gist of it.  The newbie shouldn’t even mess with trying to create commandlets until they know what they’ve got.  They also need to understand at level 2 what happens when you pass one to another.  At this level on the other hand we want to fill in the gaps.  We want to see what’s happening in the community of creating commandlets that can make our lives easier.  As is on the pyramid, the top is where the fewest are, but it’s also where the greatest power can come and few there be that find it.

One of these people up there is Gary Lapointe.  He obviously helped us out a ton with his stsadm commandlets, and now is showing us the way with his mad skills with Windows PowerShell.  I do argue that it’s most likely developers that will be able to help us out the most here.  People who hang out on codeplex and like digging into the object model.  While there may be those that say, hey now the admins have access to the object model, it’s most likely again that a developer will write the commandlet that will get us what we need.  All that talk of concern around memory leaks applies at this level.  You haven’t had to worry about that too much until this level.  Now you have to follow some dev best practices.

I am anxious to see community around this level and make our lives easier in areas where the product team didn’t think we had to go.  Will be interesting to see what we get.  One such project on Codeplex is SharePointPsScripts which includes scripts such as Get-Installed-Farm-Solutions, spReportOrphanedSites, Delete-SiteCollectionAuditEntries.  Don’t be afraid to join the fun!

Kudos to these guys: Fabrice Romelard, Stephane Eyskens, Marc Lognoul, Reza Alirezaei, Nicolas Schmitt, Christophe Rit, Sergey Zelenov, Patrick Guimonet for their contributions.  Also people to ping for help 🙂

Other people you need to get to know are Zach Rosenfield – Microsoft SharePoint Program Manager – He has spent a lot of time not only in 2010 but also in 2007 to help people write tools to help automate administration.  His resources on SharePoint and Windows PowerShell on his blog are great.  It’s to his credit the SPModule for New-SharePointFarm and New-SharePointServices for automating creation and provisioning.

Resources for this level:


Looking for even more resources?  Check out Topsy, my favorite topic based search engine on top of twitter… look at the awesome resources on “SharePoint and PowerShell

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.