Home > SharePoint 2010, SP2010 > Fun with PowerShell and Feature Activation

Fun with PowerShell and Feature Activation

I was recently working on a system where we wanted to create a site based on a previously saved site template, unfortunately when trying to create the site we were getting the error.

Error creating site: The site template requires that the Feature {some-or-other-GUID} be activated in the site collection.

Hmm, oh well, off to Site Collection Administration and I switched on all the features I could find, but still no joy, time to crack open PowerShell.

First thing to do is find the name of the feature we are looking for, this excellent post on MSDN lists all the SP2010 features and their GUID’s.

Now we know the name of the feature we are looking for its time to get PowerShelling…

Firstly lets list all the features we have installed and activated, open PowerShell from the Microsoft SharePoint 2010 Products folder from the start menu.

image

the Cmdlet Get-SPFeature is the one we are going to use, this gives us a massive amount of output, so  lets add the –Site switch, so we now have Get-SPFeature –Site <myurl>,

image

again we have lots of output, so let use the Out-File Cmdlet to pipe the output to a text file called “features.txt”, so our command is now Get-SPFeature –Site <myurl> | Out-File c:\features.txt

image

now from PowerShell all we have to do is type Notepad c:\features.txt

image

and we have a notepad file with all our site scoped features listed, a quick search for our missing GUID shows no entry, so we have to activate the feature with PowerShell, this is simply a case of typing Enable-SPFeature –Identity <FeatureName> –url <myUrl>,

image

Job done.

Advertisement

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: