Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I have a .wsp file that is deployed to the remote server by powershell script. The solution is deployed successfully and I can see the solution feature in the site collection features, I can activate this feature thru SharePoint UI, but I need activate it by powershell script.

I found that I should to use Enable-SPFeature command. In the Automating SharePoint 2010 with Windows PowerShell book says that this command is applays to features deployed via Farm and sendbox solution.

But when I tries to use command for my sandbox solution feature:

Enable-SPFeature featureName -Url siteUrl

I have following exception:

Enable-SPFeature : The Feature is not a Farm Level Feature and is not found in a Site level defined by the Url http://p s129-m. At line:1 char:17 + enable-spfeature <<<< "featureName" -Url "siteUrl" + CategoryInfo : InvalidData: (Microsoft.Share...etEnableFeature:SPCmdletEnableFeature) [Enable-SPFeature ], SPCmdletException + FullyQualifiedErrorId : Microsoft.SharePoint.PowerShell.SPCmdletEnableFeature

How can I activate sandbox solution feature on the remote server by powershell script?

share|improve this question
    
(deleted my previous coment, I'm not sure of how the feature folder name is managed in an user solution) Have you already tried to use the feature GUID instead of the feature name? That way we should be able to determine if the error is caused by the powershell sintax or some other issue. –  SPArchaeologist Oct 21 '11 at 14:08
    
thanks for advice! I tried to use the feature GUID instead of the feature name, and it works. –  Alexander Oct 21 '11 at 14:17
add comment

2 Answers 2

up vote 2 down vote accepted

When you use the Enable-SPFeature cmdlet, you have two way to specify the feature you want to update:

  • specify the folder name of the feature or
  • specify the feature GUID identifier

In your case I can only assume that the name you are using isn't recognized as the folder name of the feature you are trying to activate. To be honest, I don't know if in case of user solutions the folder name should work by specifing the name of the folder in the wsp package, so I would just use the GUID if that is a viable solution.

On the other and you could try and unzip the wsp package (it is a cab archive afterall) and confirm if you were using as the feature name the name of the feature folder in the package.

I will try to see if i can confirm the "format" to use for the feature name in case of user solutions (msdn only seems to consider features deployed to the 14 folder) and update this answer with any additional finding.

share|improve this answer
    
A little curiosity here for the interested: Since SPFeatureDefinition that is used by Enable-SPFeature uses SPFarm when it Read()'s the pipebind, it obviously cant really be used for sandboxed solutions. This triggered my curiosity to find out why it actually works (as it does) for -Identity <guid>. It turns out that in InternalValidate() of the cmdlet a SPCmdletPipeBindException is swallowed(!) and SPSitePipeBind is used to fetch site, and then a specific Read(SPSite siteScope, bool sandboxedFeatureDefinitions) is called. –  Anders Rask Jun 19 '12 at 10:30
    
^_^'... aka the "try-catch-swallow" pattern... I don't know why, but I'm NOT surprised... Anyway, nice find @AndersRask –  SPArchaeologist Jun 20 '12 at 7:13
    
yeah you don’t want to swallow exceptions to determine flow control :-S At least its not expensive in newer versions of C# (as long as you dont throw) –  Anders Rask Jun 20 '12 at 8:16
add comment

After a usersolution (a sandboxed solution) is added to the solution gallery with Add-SPUserSolution it can be installed (activated) with Install-SPUserSolution.

share|improve this answer
    
I did these steps. The solution is added and activated correctly. In the next step I tries to activate my feature that is provided by the sanbox solution. But I retrieves the exception. –  Alexander Oct 21 '11 at 14:11
    
I cannot even see the web site scoped level features through get-spfeature –  Roman Mar 15 '12 at 21:50
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.