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 have a requirement to create a site collection policy (retention policy) programmatically. It can be either a powershell script or in C# using Visual Studio 2010. I did a lot of research and am not able to find a solution. Can anybody please help.

Thanks & Regards,


share|improve this question

The documentation is a little thin for creating retention policies. Hopefully this will get you started:

share|improve this answer

@SharePointer I am sure he is talking about the Content Type Policy Templates that are found below the "Site Collection Administration" section in the site settings page.

Sure thing you can use powershell to create these policies, here is an example:

share|improve this answer

In SharePoint 2010 you can apply the retention policy to a content type, to a list or document library or to a folder.


by reading that I don't think you can apply it to site collection, did you tried any procedure manually that you want to do using coding or script ?


try this then

there is a Retention policy class at MSDN article

for example

 public static void AddPolicyToContentType()
            using(SPSite site = new SPSite("http://basesmcdev2/sites/tester1"))
                using(SPWeb web = site.OpenWeb())
                    SPList list = web.Lists["tester2"];
                    SPContentType ctype = list.ContentTypes["Document"];

                    if (Policy.CanHavePolicy(ctype))
                        PolicyCatalog pc = new PolicyCatalog(site);
                        var policy = (from p in pc.PolicyList.OfType<Policy>() where p.Name == "expireme" select p).First();
                        Policy.CreatePolicy(ctype, policy);


share|improve this answer
I didnt mean to say I want to apply a policy to a site collection (Retention policy is one of the site collection policies). Please ignore the term 'site collection policy' if its confusing. I need to basically create a retention policy programmatically. – Vishnu Sep 11 '12 at 11:15
The code that you have given, assigns a policy 'expireme' to a list and a content type. It doesnt create a policy. I need to be programmatically do the steps that are mentioned in the link - [link]… – Vishnu Sep 12 '12 at 1:04

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.