SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to activate a feature with custom properties. It is easy to do in onet.xml by providing Properties:

<Feature ID=“78277796-98D9-4276-B7D2-E3374AAC43D8“>
            <Property Key=“MyProperty1“ Value=“FALSE“ />
            <Property Key=“MyProperty2“ Value=“6ECFC841-7FFF-4E06-9D50-0678CC43696D“ />
            <Property Key=“MyProperty3“ Value=“TRUE“ />
            <Property Key=“MyProperty4“ Value=“Custom Data“/>

In Code I have seen, we can use Reflection to specify custom properties and Yaroslavs remake. How could one specify custom properties when activating feature in powershell:

Enable-SPFeature ...
share|improve this question
up vote 1 down vote accepted

It's not possible throught Enable-SPFeature if you need it you'll have to write your own cmdlet, there a guide for doing that here

In that cmdlet, you can use the reflection hack you linked to, but note that when you're using reflection to find non-public methods you run the risk of any update/hotfix/SP breaking your code.

share|improve this answer
Thank you for your answer. I agree with you. It isn't reliable to use reflection because a new patch can change internal methods. But I was curious about creating cmdlets, so I created this one: sp-lend-id.taprat The description is on my blog – Anatoly Mironov Apr 10 '12 at 20:15

It sounds like what you have is a configurable component. If that is the case, you should implement configuration properly instead of hacking/reflecting an object to make is suit your purpose.

The patterns & practices group discusses configuration in "The Application Setting Manager" section of their guidance. The guidance also includes sample code for a List-backed configuration store.

share|improve this answer
Thank you for your answer! Could you provide an example how to implement the configuration "properly"? – Anatoly Mironov Apr 5 '12 at 13:40
Read content at the provided link. – Paul Schaeflein Apr 5 '12 at 13:41
Allright, one can do much with Application Settings Manager like creating new configurations when activating feature But how can we put properties into the feature when we enable it? – Anatoly Mironov Apr 5 '12 at 13:58

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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