I want to activate a custom feature with PowerShell on a few sites in my environment.

When I´m doing this job over the GUI, everything is perfect.

But when I´, doing it with my script, the feature is activate in the feature list, but nothing happens.

  • Why is the GUI and script activation different?
  • How can I fix my script?

Thank you in advance!

My code snippet:

Enable-SPFeature FeatureID -Url https://test-portal.sharepoint.de/ -ErrorAction Stop

also not working

Enable-SPFeature -Identity "FeatureName" -Url https://test-portal.sharepoint.de/ -ErrorAction Stop
  • 1
    These weird errors usually happen for me when PS is caching old versions of files (esp. wsps). I guess you've tried to restart PowerShell?
    – tarjeieo
    May 8, 2012 at 13:21
  • Sure :-( This can´t be the reason for my problem
    – LaPhi
    May 8, 2012 at 17:13
  • What does your feature do? Custom code in activation event receiver?
    – tarjeieo
    May 9, 2012 at 6:33

3 Answers 3


Usually this happens if you have feature activated event receiver and use http context in code somehow (accessing to SPContext.Current or creating web part, that might use internally Http context). When you activate your feature through UI, Http context is not null and all may work as expected, but when activating through PS or stsadm Http context is null and this may lead to unexpected behavior.


Is your feature assembly GACed? If not, make sure the feature assembly is located someplace where powershell can find it.


If your code references something that only the IIS worker process can see (like web.config) it might fail. PowerShell's execution environment is different than the running web application.

  • The OP is asking about an OOTB SP cmdlet, there is no custom code here. Oct 4, 2012 at 17:41
  • Custom code most certainly CAN run during a cmdlt like Enable-SPFeature. There are event receivers specifically made to allow solution developers the opportunity to do something during install, upgrade and activation. Check MSDN.
    – ArbutusJoe
    Dec 14, 2012 at 17:05
  • That's not what I was asserting. I was questioning the relevancy of your answer to the OP. Dec 14, 2012 at 23:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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