Learn PowerShell & SharePoint: A Beginners Reference Guide to Get Started

Category: SharePoint

Please rate this blog post!

Most likely you are familiar with what PowerShell is and have a general idea about what it can do. Perhaps you are finding yourself in one of the following situations:

  • You have used a few cmdlet’s like Get-SPWebApplication or  Install-SPSolution.
  • You already know about Get-Help and the PowerShell command builder.
  • You’ve copied every script you found on someone else’s website but now you need to make your own.
  • You have seen some webinars, videos or demos, but it seems people are going about doing it in different ways using different tools/scripting environments and you are confused.

Yes folks, it appears you are ready for the next phase; learning SharePoint PowerShell programming.

Over the past few weeks I have been searching for some guidance on how to move into this next phase of learning but had to piece together fragments I have found all over the place to get myself started. I found some blog posts about different levels of learning PowerShell & SharePoint and an article on the PowerShell learning roadmap,  but I wanted a bit more of a “please tell me what to do” article.

I have tried to sort out the best way to approach this challenge and hope it will help someone (other than myself) learn how to advance their knowledge or simplify learning PowerShell for SharePoint.

1. Get Your Scripting Environment (s)

Notepad++ Free, popular, basic text editor.
PowerShell ISE The free, Windows PowerShell script editor. It is a feature on Windows 2008 to be installed. If you cannot find it, look to see if it was installed on the Windows server in the Features section first.
PowerGUI I believe this tool use to be owned by Quest (which is now Dell), however it is free. Watch a demo or get help if you run into issues running scripts with PowerGUI.
PowerShellPlus A free tool from Idera.
Primal Script I am not sure if this tool is free or only has a free trial.
Visual Studio w/PowerGUI extension From what I can tell, to use Visual Studio to write PowerShell scripts, you need to install the PowerGUI Visual Studio extension (same product line as listed above). You can actually create your own cmdlets and other advanced features if you are really smart but I will save this topic for another day.
The SharePoint Management Shell command window This is not the same as the Windows PowerShell window where you have to add the snap-in, however either could be used. In my opinion, these aren’t the best for learning as there is no robust debugging functionality.

I am currently alternating scripting editors to find what works for me. I am using PowerGUI the most at this time for the type-ahead and debugging features. Here is a post on why some like using the PowerShell ISE however.

2. Find Available Methods & Properties

So now that you know you want to start doing some cool things, where do you get the list of all of the properties and methods available so you know what you can do? For example, if I needed to know all of the Site Collection owners in my farm, how would I know there was an owner  property even available for me to use? I don’t have the SharePoint object model memorized and finding what  was available for my needs in the current context was difficult. I have found 2 solutions thus far:

  • Get-Member will show you all methods & properties for that cmdlet (thanks to Todd Bleeker from his SPSVB presentation for this tip):

Example of using get-member to obtain all site collection methods and properties available to use:

$siteName = get-spsite
$siteName | get-member

get-member

 

 

 

 

 

  • PowerGUI has a right window panel to display available methods & properties while debugging:

PowerGUIMethodsProperties

 

 

3. Find Good Examples

So far it appears that PowerShell scripts for SharePoint are pretty much scattered all over the internet. I will be creating a resource page soon but here are some repositories to get you started:

4.  Find Good Learning Resources

I will also create a list for this soon, but a good starting point for me was the few books available specifically for SharePoint PowerShell scripting. I am currently following along with Microsoft SharePoint 2010 and Windows PowerShell 2.0:Expert Cookbook by Yaroslav Pentsarskyy  at the moment, but here are some other books & videos too:

SharePoint Specific PowerShell Resources

Non-SharePoint Specific PowerShell Learning Resources

 

Other Cool Tools & Add-Ons

A World of Scripts at your Fingertips – Introducing Script Browser – (allows you look up on the internet over 10,000 script examples into the PowerShell ISE) – MSDN

Final Thoughts…

  • Have awareness there are now different versions of PowerShell and some code will work in one version that will not in another (get ready for PowerShell V4.0 too! Scratch that… AUGH PowerShell 5.0 Already?!?!)
  • Please…don’t experiment with any scripts on any environment that cannot be considered disposable. To quote Todd Bleeker, “You shouldn’t be allowed to use PowerShell if you can’t restore your farm”.
  • Understand that the best learning will come from practice and actually doing. If you don’t have a SharePoint playground, check out my blog post on SharePoint development environments to get one up and running.
  • Thanks to Todd Klindt for some of the links and the humble inspiration.
5/5 (1)

Leave a Reply

Your email address will not be published.