locked
Feature activation via GUI works fine on every level, but not via PowrShell RRS feed

  • Question

  • Hi *,

    I have experiencing an issue with my PowerShell installation scripts. The script for activating the features (web, site and web application level) goes through without any error, not event in logs or ev. viewer but the features (that seem activated) don't have the functionality added completely, meaning: the feature that creates the list, ct, fields creates them right but does not pick up the resource files; the features for pages modifies the default page but does not add the other pages to the Pages library. Some features don't seem to get activated at all, they state Activated but the functionality is missing. 

    In the code I have tried logging all the error thrown, but nothing came up. I have no references to SPContext.Current or HttpContext in the feature event receivers, I run PowerShell with admin rights.

    Also when I try to add items to a list via PowerShell, no event receivers on the given list are executed.

    Also if I activated the features from SharePoint UI everything settles just fine and I have my application running as expected. Even if I activate the features via UI the adding of item from PowerShell does not trigger the event receivers. Adding the item from UI triggers the event receivers.

    Any idea is greatly appreciated.

    Thank you,

    Anisia Pop

    Monday, May 12, 2014 8:08 AM

All replies

  • hi

    it may happen if your Windows default language is not the same as language of Sharepoint site and resources which you try to use on it. In this case Powershell thread's language will use OS language and feature receiver will be executed under this language. From other side when you activate the feature from UI, feature receiver's thread has language of the site on which it is activated (Sharepoint automatically sets thread's language to the language of accessed site, see e.g. How Sharepoint sets CurrentThread.CurrentUICulture depending on Language of SPWeb). As workaround try explicitly set language of the current thread in PowerShell before to activate the feature.


    Blog - http://sadomovalex.blogspot.com
    Dynamic CAML queries via C# - http://camlex.codeplex.com

    Monday, May 12, 2014 8:50 AM
  • Hi,

    Thank you for answering. The language of the web is English. I do have resource for English in my solution. I forgot to mention that the language for which this feature does not work is English (the default). For the other 2 (french  and nederlands) works fine from the start. And the translations are not made for the list names only.


    Pop Anisia

    Monday, May 12, 2014 1:11 PM
  • if your resource files are located in 14/Resources folder, ensure that they are also copied into App_GlobalResources subfolder in your site's virtual folder under c:\inetput\wwwroot\wss\virtualdirectories\....

    Blog - http://sadomovalex.blogspot.com
    Dynamic CAML queries via C# - http://camlex.codeplex.com

    • Marked as answer by star.wars Sunday, May 25, 2014 8:19 AM
    • Unmarked as answer by Pop Anisia Monday, May 26, 2014 6:24 AM
    Tuesday, May 13, 2014 10:59 AM
  • The resources where copied in the virtual directory as well, so no issue with that.

    The solution we resorted to in the end was manual activation which was working all along.


    Pop Anisia

    Monday, May 26, 2014 6:26 AM