Add User To SharePoint Group Programmatically with STSADM and C#

Apart from SharePoint User Interface, We can programmatically add users to SharePoint group or site in these ways: Using STSADM command-line tool to add users  Add users to Sharepoint site/group using C# Object Model 1. Using STSADM command-line tool to add users: To add users to the SharePoint site, we can use…

Read more

How to Rename SharePoint Column Programmatically (PowerShell / C#)?

Here is how we can rename SharePoint list or site field or column programmatically with PowerShell and C# object model code: PowerShell script to Rename a SharePoint Field: Rename a SharePoint Field Programmatically (C#): PowerShell to change field display name in SharePoint site collection: Similarly, to rename a site column, use:

Read more

Set SharePoint Search Settings (Search Center URL, Scope Dropdown Mode) Programmatically

After migrating SharePoint 2007 sites to SharePoint 2010, we decided to set search center URL to a Enterprise Search center site and scope settings Dropdown mode to use “Show scopes dropdown” for all site collections. To update search center and search scope dropdown settings in SharePoint sites, We used to go: Site…

Read more

SharePoint Document Versions Size Report with PowerShell

This is a PowerShell version of my existing post Version History Size Report for SharePoint which uses C# object model to generate a versioning report and gives insights, such as: Site/Library’s Total versions size Total No. of versions created Which documents are with more versions Type of the documents Library in which…

Read more

Change Site Collection Primary, Secondary Administrators in SharePoint

Site collection administrators have god-like power within a SharePoint site collection, They can add/delete sites, content, users, etc for any site within a site collection. These administrators are responsible for administering their site collection and are recipients of any site status and resourcing Email notifications. How to change the site collection administrator…

Read more

Hide Columns in SharePoint List NewForm, EditForm and DispForms

Had a requirement to hide a specific column “Parent Project” in a SharePoint list “Project Metrics”, Since this field was being updated by an internal workflow, it must not be visible in NewForm or in EditForm. So to protect a particular column from edits, decided to hide it from New & Display…

Read more

Create Folders and Sub-Folders in SharePoint Programmatically

How to create Folders in SharePoint? To create a folder in SharePoint list or Library, follow these steps: Navigate to your SharePoint list or library From the “Files” tab on the Ribbon, click on the “New Folder” button Give a name to your new folder and click “Save” What if you don’t…

Read more

Get SPWeb Object from the URL

PowerShell Snap-in for SharePoint 2010 offers Get-SPWeb cmdlet to get SPWeb Object directly from the given web URL. But when writing .Net code in C# (or in PowerShell with MOSS 2007) SharePoint object model doesn’t offer this mechanism. However there is a Trick to get SPWeb Object from given URL: Get the…

Read more

Hide SharePoint 2007 List Toolbar buttons and Menu Items

Got a requirement to Hide SharePoint toolbar buttons (E.g. “New”, “Upload”), Menu Items (E.g. “Upload Multiple Files”, “Alert Me”) from all document libraries of a SharePoint 2007 site collection. If its is for just a single document library, this can be achieved by wring Javascript-CSS, place it in Content Editor web part…

Read more

Attach Event Receiver to Specific List Programmatically in SharePoint 2010

Recently, developed an Event Receiver to set Item Level permissions based on the list field “Visible to Visitors”. Event receiver binds with all document libraries using ListTemplateId element in Elements.xml.  Event Receiver to Set Item Level Permissions based on List Column Value How to Associate an Event Receiver with a List Programmatically…

Read more