Basics: Enable/Disable features via the SP2010 Management Shell

There will be a time that because of your custom code or for any other reason, SharePoint will refuse to operate as expected. Unfortunately, when SharePoint gives a JavaScript error in the Site Collection Features page, this means that you’re out of luck when trying to activate or deactivate a specific feature; even if it’s the one responsible for the JavaScript error in the first place.

What do you do when you have pinpointed the reason behind the page not loading correctly but, you can not solve it because clicking on the Deactivate Feature button does nothing? At that point, your best bet is to dig into the Powershell and do there what you originally wanted to do through the GUI.

Load up the SharePoint 2010 Management Shell (which is nothing more than the Windows Powershell with SharePoint Extensions). You will find the link in your Start Menu > All Programs > Microsoft SharePoint 2010 Products > SharePoint 2010 Management Shell.

If you’re running the management shell for the first time, expect it to take some time. After it loads up, you will have to first find your malfunctioning feature and then deactivating it, before you eventually remove it altogether.

In order to list the features you will need to use the command: Get-SPFeature. This command however, will list all the features in your SharePoint installation. You can use many switches to narrow down your results but I found the following to my liking. It lists all the features within a specific scope. I use Site for scope and then I scan through the list till I find the feature I’m looking for: Get-SPFeature -Limit ALL | Where-Object {$_.Scope -eq “Site”}

It goes without saying that you will need to change the scope to reflect what you are looking for. Scopes are Farm, WebApplication, Site, Web.

Scan through the listing and locate your misbehaving feature. As soon as you locate it, right click and select Mark from the drop down menu. You will need to mark the GUID that is next to the specific Feature. Right click again as soon as you have marked the GUID. This copies the contents into the clipboard. Now, you need to deactivate the feature. The command you need is: Disable-SPFeature.

You do need a bit more than than, however. You will need to type in the command, followed by the GUID you just copied and then the location where the Feature is active. To illustrate: Disable-SPFeature “GUID” -Url “url”. Do note the -Url switch. You need this before the actual URL. As soon as you run this command, the system will ask you for confirmation and after you select Y, which is the default anyway, the feature will be deactivated.

I order to totally remove the feature, you need the Uninstall-SPFeature command. It’s straightforward to use, you just type the command followed by the GUID and that’s it. The system will again ask for confirmation and after you say Y, which again is the default, the Feature will be removed. To illustrate: Uninstall-SPFeature “GUID”.

  1. for a pretty amazing post on the various switches and uses of the above commands/sniplets, jump to the SharePoint Analyst HQ.
MGR: the Intelogist

About MGR: the Intelogist

SharePoint Server developer, turned Sitefinity developer, turned Angular developer, turned SharePoint Online consultant, turned Unily consultant, turned O365 consultant... Never a dull moment!

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> 

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