Question

I have a Sandbox feature that was deployed to my SharePoint 2013 environment. I say "Sandbox" because if I run:

Get-SPFeature

It doesn't come up in the list. But if I run:

Get-SPFeature -Site <site url>

Then I can see my feature. Now, I'm trying to remove it using:

Uninstall-SPFeature -Identity <guid>

However I get the following error:

Uninstall-SPFeature : Cannot find a Feature object with Path or Id: <guid> in scope Local farm.
At line:1 char:1
+ Uninstall-SPFeature -Identity <guid>
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidData: (Microsoft.Share...ninstallFeature: SPCmdletUninstallFeature) [Uninstall-SPFeature], SPCmdletPipeBindException
    + FullyQualifiedErrorId : Microsoft.SharePoint.PowerShell.SPCmdletUninstallFeature

So I can only assume that this command only removes farm features from the server, and the TechNet page doesn't explicitly say anything about this. How can I remove this feature then?

EDIT 1: It may be worthwhile to know that I installed this feature through a sandbox solution WSP, by uploading it to the Solutions gallery and activating it there as discussed in this post.

EDIT 2: Thanks for all the answers so far. I've sort of managed to remove it using Uninstall-SPUserSolution and then Remove-SPUserSolution. I say "sort of" because the feature doesn't show up anymore when I do Get-SPFeature, nor the solution when I do Get-SPUserSolution. Apparently the feature was packed inside a sandbox solution. However the problem is still not solved, because the only thing the feature does is to deploy a site page like http://blablabla/FeatureDeployed, and so although the feature and the solution were removed, the site page still remains in the same address. Shouldn't the site page be deleted when the feature is removed?

Was it helpful?

Solution

I think the Powershell commandlets you are looking for are:

Disable-SPFeature, which is the equivalent of going to the "Manage Site Features" page and clicking the "Deactivate" button. Disable-SPFeature has a Force parameter, and a URL parameter which:

Specifies the URL of the Web application, site collection, or Web site to which the Feature is being disabled.

so you can target it to the specific scope necessary.

And then you want:

Uninstall-SPUserSolution, which is the equivalent of going to the Solutions Gallery on the site collection and clicking "Deactivate"

And:

Remove-SPUserSolution, which is the equivalent of going to the Solutions Gallery on the site collection and Deleting the sandbox WSP file from the Solutions Gallery.

OTHER TIPS

I saw a similar behavior once when a feature became "orphan" following some error during a solution upgrade test in one of my development environments. Some of the info you give aren't really strict, so forgive me for my guessing, but here are some info that saved me back then.

Turns out that the Uninstall-SPFeature -Identity <guid> command is the most "vulnerable" and prone to crash if the feature is in an invalid status. You should try some equivalent way to delete the feature and see if that work instead - otherwise we may need more info to diagnose the problem.

For starting - try using the display name of the feature instead of the GUID (see this example for further details), then call .Delete() on the resulting feature definition instance. This worked for me once.

$featureToDelete = Get-SPFeature -Site "<siteurl>" | ? { $_.DisplayName -eq "Feature display name" }
$featureToDelete.Delete()

If even this fail, it may be worth giving good ol' stsadm a try:

stsadm -o uninstallfeature -id <Guid>

Its internal implementation isn't the same of the Powershell based version, and even if deprecated isn't rare for PowerShell to actually work for situations where PowerShell fails...


UPDATE: based on the latest update to the question, the problem wasn't a "stuck/corrupted" state for the feature in the SharePoint configuration db like I feared, but simply a missing step in the sandboxed solution removal process. For these reason the above info are made obsolete in a way - I will still leave them here as a reference hoping that they may be useful to others users with similar problems, but I will convert the post to community wiki.

If you want to disable Sandbox Solutions (I'm assuming that is what you mean by Sandbox), you can just stop the Sandbox service in Central Admin -> Manage Services on Server, and stop the Microsoft SharePoint Foundation Sandboxed Code Service.

Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top