What is PowerShell and why should I use it?

Windows PowerShell is an extendable command shell and scripting language which can be used to manage/administer server environments like Windows Server, Exchange and also SharePoint 2010.

The above PowerShell definition has two things that stick out to me: “extendable” and “scripting language”. Extendable sticks out because it means I can add value to this environment by extending it with my own tools (cmdlets) so I can:

  • make repetitive tasks easier and less tedious.
  • make complex tasks less complex by wrapping several commands together.
  • automate some tasks like e.g. deployment which reduces the risk of human error.
Secondly “scripting language” gets my attention because I am a developer. When doing a bit more research on the scripting language I find that it is based on C# en build on top of and integrated with the .Net framework. So for me as a developer it is easy to learn. 

Pre-PowerShell we used to do all sorts of tasks with all sorts of tools 

  • Central Administration website
  • the SharePoint Products Configuration Wizard
  • stsadm
  • psconfig
These can all be replaced by PowerShell.

Windows PowerShell 2.0 is already in Windows 7 and Server 2008 R2. If you’re not working on Windows 7 or Windows server 2008 R2 you get get instructions here. The containing folder of PowerShell 2.0 is, confusing as it may be, still named 1.0. If you’re not sure, just start up PowerShell and type “get-host”.

Windows PowerShell get-host

Windows PowerShell get-host

The cmdlets used in PowerShell are typically made up out of a verb and a noun as can be seen in the above get-host example. To help you with these cmdlets and create working scripts, Microsoft have created a tool: the Windows PowerShell Command Builder.

For people who don’t like the old-school blue command line console look, or are looking for some more advanced features, there are several third party tools available:

 However, MicroSoft also ships its own Grapihical editor calle PowerShell ISE, it has some nice features:

  • A Command pane for running interactive commands.
  • A Script pane for writing, editing, and running scripts. You can run the entire script or selected lines from the script.
  • A scrollable Output pane that displays a transcript of commands from the Command and Script panes and their results.
  • Up to eight independent Windows PowerShell execution environments in the same window, each with its own Command, Script, and Output panes. This tabbed environment allows you to work on several tasks at the same time.
  • Multiline editing in the Command pane lets you paste multiple lines of code, run them, and then recall them as a unit.
  • A built-in debugger for debugging commands, functions, and scripts. You can set and remove breakpoints, step through your code, check the values of variables, and display a call-stack trace.
  • Customizable features let you adjust the colors, font, and layout.
  • A scriptable object model lets you further customize and extend Windows PowerShell ISE. You can add functionality, including menu items. Also, you can access the session, the files, and the editor to create your own features.
  • Line and column numbers, keyboard shortcuts, tab completion, context-sensitive Help, and Unicode support make Windows PowerShell ISE an efficient and productive environment for using Windows PowerShell. Windows PowerShell even lets you open files by using a drag-and-drop operation.
PowerShell ISE

PowerShell ISE

The only setback, out of the box, it does not support SharePoint, luckily Spence Harbar has found a solution for that.

Last but not least, if you want to use PowerShell for your SharePoint online environment there are some things that need to be done, it will not work out of the box, there is a blogpost by Jeffrey Paarhuis called Scripting SharePoint Online with PowerShell using Client Object Model which will get you up and running.

With that said, I’ll leave it up to you whether you like PowerShell or not and if it’s something to further explore. Untill next time, happy SharePointing!

Error: Feature ‘GUID’ for list template ‘XXX’ is not installed in this farm. The operation could not be completed.

While playing around in an existing SharePoint environment I came across the following error: Feature ‘GUID’ for list template ‘XXX’ is not installed in this farm. The operation could not be completed. It occured while clicking on a list, I wanted to delete it. The cause of the problem is probably that someone deleted the feature that came with this list. A colleague of mine told me that I perhaps could delete it by manually changing the url: http://SharepointUri/_layouts/listedit.aspx?List=SomeGuid. It displays the list settings. To do that you first need to get the list Guid, that was the second challenge, there was no way for me to get the guid because I need the settings page to see the Guid. So I decided to write a small program to get the Guid of a certain list. After obtaining it I used it with the url but to no avail, I got the same error.

After searching the internet I came across 2 possible solutions, use stsadmin with a forcedelete command or use PowerShell. And I found out PowerShell is the way to go. It is a commandline tool with a syntax much like C#:

$w = Get-SPWeb “http://MySharePointURI”

$w.Lists.Delete([System.Guid]$w.Lists[“List Name To Delete”].ID)

What we do here is set “w” to be instantiated with the web that holds the list. Next call the delete method on the list collection of the instantiated obeject. The Delete method takes a Guid. We get the Guid with $w.Lists[“List Name To Delete”].ID it gets the Guid based on the name of the list.