Day: January 25, 2014

This script works doing a PING request and obtaining its resultant IP. Feel free to change it and modify it as you need. First part does the PING request, second part changes the Host File and the third part opens the hosts file. Explanation of the secon part: 1. Save the Hosts File text in […]
SPSecurity.RunWithElevatedPrivileges(delegate() { using (SPSite site = new SPSite("YOURSITE")) { using (SPWeb web = site.OpenWeb()) { //Obtain the page PublishingPageCollection publishingPages = PublishingWeb.GetPublishingWeb(web).GetPublishingPages(); PublishingPage page = publishingPages.FirstOrDefault(f => f.Uri.AbsoluteUri == "YOURPAGE"); if (page != null) { //Allow modifications bool webAllow = web.AllowUnsafeUpdates; web.AllowUnsafeUpdates = true; SPFile file = page.ListItem.File; //Delete file.Delete(); //Restablish default permissions web.AllowUnsafeUpdates = […]
Unpublish and Checkout SharePoint Page: SPSecurity.RunWithElevatedPrivileges(delegate() { using (SPSite site = new SPSite("YOURSITE")) { using (SPWeb web = site.OpenWeb()) { //Obtain the Page PublishingPageCollection publishingPages = PublishingWeb.GetPublishingWeb(web).GetPublishingPages(); PublishingPage page = publishingPages.FirstOrDefault(f => f.Uri.AbsoluteUri == "YOURPAGEURL"); if (page != null) { //Allow file modifications bool webAllow = web.AllowUnsafeUpdates; web.AllowUnsafeUpdates = true; SPFile file = page.ListItem.File; //Unpublish […]
This is a function in order to create a CAML Query specified for Filters. Once we have the filters, we’ve to create the parameters for the function, following this template: Parameters Template Name1|Type1|Operation1|Value1,Name2|Type2|Operation2|Value2... [Operation property can only be "Equal" or "Contains", 'cause that's what I need, but it can be modified] Example Title|Text|Contains|Document,Category|Choice|Equal|Docs [Filter items […]