This is the beginning of a blog series that’s aimed to help some folks get comfortable with PowerShell when working with SharePoint. It began several months ago as a few emails and some quick things that I’d show people in my group. Whenever there was a PowerShell or SharePoint question and I thought I could help out a little, I’d show off a quick, neat little thing that made that day’s task a little easier. These days, I’m on the road with the collected tips, talking about it at local SharePoint user groups and SharePoint Saturdays. My group has since internalized all the content and moved on. I often hear them joke in my direction: “there’s a PowerShell command for that!”

The premise is this: there’s an indispensible tool out there that’s free and always available, but so many people aren’t using it. Back in the days of SharePoint 2007 — imminent sunset or not, these days are still very much alive for some — you had one tool, stsadm, to manage SharePoint from the command line. For most people, until you ran across something that couldn’t be solved through the UI, stsadm was something that lived in some obscure BIN directory somewhere. With SharePoint 2010 came a more powerful and versatile tool that runs side-by-side with stsadm, doing everything it does and much, much more. It comes free with your SharePoint install; PowerShell itself comes free with the OS and the SharePoint installation adds the snap-in to allow you to use PowerShell to manage SharePoint.

But why? What’s this DOS-like, text-based thing I have to use to add a solution to my farm? For a few reasons. For starters, it’s repeatable. Run a command, copy it into a text (script) file, then run it again later, maybe the first time in a development environment and later in a test or production environment. Anyone who’s ever tried to automate something UI-based can tell you that the approach has… well, drawbacks. Then let’s not forget the optimized reliability of text commands. One kilobyte of script can do a lot. You don’t need a high-resolution screen, lots of RAM or dual quad-cores to run it. We don’t even need rotating hourglass cursors because commands execute quickly. Throw in some versatility too: PowerShell can control not only SharePoint, but your local machine, SQL Server, WMI, and much more. To top it all off, once you know how to do something in PowerShell — maybe you’ve even written a script to automate a small piece of something — you can do it again easily, much easier than having to re-click on all the checkboxes and buttons the UI would take.

We’ll start this series with the content from the talk I’ve been giving. (Want the slides? Download them here.) The premise for the demos is that we’re sorting a document library full of company photos. Some have spaces in the names and we can’t use that, so we want to move them all to a folder. Someone will come along later and rename them. For demonstration purposes, I only have 15 pictures but in a real situation, that could be 15,000. Create your own if you like to follow along, call the document library Company Pictures if you want minimum hassles.

That’s all for now, I’ll have the first tip up soon.