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.

1

2 Answers 2

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

1
  • Your 2. will not work on a site scoped feature as stated in the question... Commented Apr 9, 2014 at 8:26

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.