0

I am new to powershell deployment, and little confused with features and scopes.

We deploy feature via PowerShell. Code:

$solution="myfeature.wsp"
$path= $solutionPath + $solution 
Add-SPSolution -LiteralPath $path
install-spsolution -Identity $solution  -GACDeployment 
WaitForJobToFinish
    $FeatureID='the ID'
    $Feature = Get-SPFeature -Identity $FeatureID -Site $oURL -ErrorAction SilentlyContinue
    Enable-SPFeature -Identity $FeatureID -Url $oURL  -Confirm:$false

Suppose if the feature scope is web level, then, what URL should we use?

Suppose the feature scope is site level and I want to activate it only for one of the webs(subsites), then what should be the URL? -Let me know if this is not feasible.

2
  1. You should use the URL to the web where you want to activate it. But you should change line 2 in the script to use -Web instead of -Site for web scoped feature
  2. If it is site scoped it will be activated at Site Collection level and not web level, so your question is not applicable
1
$FeatureName = "YourFeatureName"
Install-SPFeature $FeatureName -Force
$FeatureActivate = Get-SPFeature $FeatureName
Enable-SPFeature -Identity $FeatureName -Url $Url -Force

We can change the url based on scope 1.

Enable-SPFeature -identity "MyCustom" -URL http://somesite

This example enables the "MyCustom" site scoped SharePoint Feature at http://somesite.

2.

$w = Get-SPWeb http://somesite/myweb | ForEach{ $_.URL }
Get-SPFeature -Web $w |%{ Enable-SPFeature -Identity $_ -URL $w}

This example enables all SharePoint Features in the subsite at http://somesite/myweb.

reference: http://technet.microsoft.com/en-us/library/ff607803(v=office.15).aspx

  • Your 2. will not work on a site scoped feature as stated in the question... – Robert Lindgren Apr 9 '14 at 8:26

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.