Empty SharePoint Recycle Bins Programmatically with PowerShell

Requirement: Empty recycle bin in SharePointIn a Database attachment method migration project, we decided to clear all the recycle bins to get some additional free space in databases. There were 3000+ site collections. Automation? SharePoint Automation = PowerShell 🙂 Empty SharePoint Site Collection Recycle bin using PowerShell: The Recycle bin in SharePoint…

Read more

Create Shortcut in SharePoint Document Library

The requirement is to create a Shortcut link inside the SharePoint document library. OK, tried uploading the URL shortcut (.url) file, and got the error message saying “The following file(s) have been blocked by the administrator: URL Shortcut.url”. Solution: Add “Link to a Document” content type to the document library. Here is…

Read more

Install Features Programmatically in SharePoint

Generally, we use STSADM command line to install features by “STSADM –o installfeature –name FeatureName” or Install-SPFeature PowerShell Cmdlet. At times, we may have to execute stsadm programmatically to install a Feature. Say for e.g. from console applications or from another feature activation code.  Here is how it can be achieved.

Read more

How to Create Site Columns Programmatically in SharePoint?

Requirement: Add Site columns to the SharePoint site programmatically as part of a site provisioning code. Add a New Site column to SharePoint Site Programmatically:   Create SharePoint site column programmatically with C# Object Model code: Alternate Approach:

Read more

Deploy Custom List templates(.stp) as Feature-based Solution in SharePoint

Requirement: Had a custom List template, and wanted to make it available in create page of all sites of the site collection. Solution:  How to deploy a SharePoint list template? Create a WSP builder solution to deploy the .stp file to the List template gallery of required site collections! Just create a…

Read more

Delete Attachments from SharePoint List Items using PowerShell

Requirement: Delete Attachment from SharePoint List Item How to Remove an Attachment from a List Item in SharePoint? There is a requirement to delete all the attachments named as “xyz.presales.document.docx” from a SharePoint List where 100’s of list items already created with a lot of attachments. Attachments can be removed from a…

Read more

How to Add Web Parts to the Page Programmatically?

Requirement is to add OOTB and Custom web parts to a web part page programmatically via features. I’m sharing the code snippets: To Add Out Of The Box Web Parts: (E.g. Content Query Web Part, Content Editor, Page Viewer Web Part, etc): Add Page Viewer web part: Programmatically add ListView webpart from:…

Read more

SharePoint List Template Registration IDs Reference

Reference Table for SharePoint List Registration ID: ID Name 100 Generic list 101 Document library 102 Survey 103 Links list 104 Announcements list 105 Contacts list 106 Events list 107 Tasks list 108 Discussion board 109 Picture library 110 Data sources 111 Site template gallery 112 User Information list 113 Web Part…

Read more

Event Receivers vs Workflows – Decide Which One to Use

As SharePoint Event Receivers & SharePoint workflows have a lot of similarities, Many people stuck on deciding which one to go with: Event Receiver or Workflow? event receiver vs. workflow in SharePoint is always tricky to decide. Differences Between SharePoint Event Receivers and SharePoint Workflows: 1. Event handlers Can’t be manually initiated…

Read more