2

We have deployed a wsp using:

Add-SPSolution -LiteralPath $path
install-spsolution -Identity $solution  -GACDeployment -Force

This wsp has 2 features, one scoped at application level (FeatureA) and one scoped at site collection level (FeatureB). Both can be seen and activated/deactivated from the respective UI's.

I would like to know how to activate them via powershell.

I tried:

Enable-SPFeature -identity "FeatureB" -confirm:$false -url $oUrl

Gives error as:

Enable-spfeature : The Feature is not a Farm Level Feature and is not found in a Site level defined by the Url http://dewswift:7676/. At line:1 char:1 + Enable-spfeature -identity "FeatureB" -confirm:$f ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidData: (Microsoft.Share...etEnableFeature:SPCmdletEnableFeature) [Enable-SPFeature], SPCmdletException + FullyQualifiedErrorId : Microsoft.SharePoint.PowerShell.SPCmdletEnableFeature

  • are you working with sharepoint online? – Salvatore Di Fazio Apr 7 '14 at 12:21
  • no the in house intranet, not sharepoint online – variable Apr 7 '14 at 12:23
3

First check if the feature is installed using Scope and then try to activate it like:

$Feature = Get-SPFeature -Identity $FeatureID -ErrorAction SilentlyContinue
If ($Feature.Scope -eq [Microsoft.SharePoint.SPFeatureScope]::WebApplication)
{
    $Feature = Get-SPFeature -Identity $FeatureID -WebApplication $SiteUrl -ErrorAction SilentlyContinue
    Enable-SPFeature -Identity $FeatureID -Url $SiteUrl  -Confirm:$false 
}
ElseIf ($Feature.Scope -eq [Microsoft.SharePoint.SPFeatureScope]::Site)
{
    $Feature = Get-SPFeature -Identity $FeatureID -Site $SiteUrl -ErrorAction SilentlyContinue
    Enable-SPFeature -Identity $FeatureID -Url $SiteUrl  -Confirm:$false 
}
  • How to get FeatureID – variable Apr 7 '14 at 12:32
  • 1
    It is present in Feature manifest file. – Nadeem Yousuf Apr 7 '14 at 12:38
  • 1
    within the IF loop why have you used $Feature = Get-SPFeature -Identity $FeatureID -WebApplication $SiteUrl -ErrorAction SilentlyContinue? – variable Apr 8 '14 at 4:32
1

This has happened to me when I try to enable a feature from a SharePoint server that does not have the SharePoint service running: Microsoft SharePoint Foundation Web Application . The web sites are not hosted on IIS on these servers and the layouts folder do not have the features deployed to them! A common practice is to turn off the Microsoft SharePoint Foundation Web Application on a dedicate APP/Central admin server. But then you cannot enable features.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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