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 ...

2 Answers 2


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.

  • 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 Apr 10, 2012 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.


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.