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,


3 Answers 3


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



@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:



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);


  • 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, 2012 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]office.microsoft.com/en-us/sharepoint-server-help/…
    – Vishnu
    Sep 12, 2012 at 1:04

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.