Property Bags in SharePoint – Store, Retrieve Custom Configurations

As its name suggests, the Property bag feature provides a convenient way to store and retrieve custom configurations instead of storing them in the web.config files. Property bags in SharePoint store configuration data in the Hash-Table (Key-Value) format. We can store and retrieve properties at the following levels:

  1. Farm (SPFarm )
  2. Web application (SPWebApplication )
  3. Site collection (SPSite – Doesn’t has Property Bag, but you can use SPSite.RootWeb )
  4. Site (SPWeb )
  5. List (SPList )
  6. Folder (SPFolder)
  7. File (SPFile)
  8. List Item (SPListItem)

Property bags can be created, edited and deleted at all of these levels. Property bag keys are case-sensitive!

How to use property bag SharePoint?

If your SharePoint application uses any specific setting for each SharePoint object, such as Web Application, Site Collection, Site, etc., you have to maintain those entries in the config files. Here is where SharePoint property bags can be a great helper.

There is no out-of-box user interface to manage property bag settings in SharePoint. We use object model codes to set/get properties programmatically. Any method that interacts with SharePoint object properties such as AddProperty, DeleteProperty, GetProperty, SetProperty doesn’t affect the “Properties” property. You have to access “AllProperties” instead. “Property” property is available for backward compatibility.

Managing SharePoint Property bag using PowerShell:

Here is an example of managing Property bags at the site level using PowerShell

Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue

$WebURL =""
#Get the Web Object
$Web = Get-SPWeb -Identity $WebURL

#Variables for Key-Value 
$PropertyName ="masterPage"
$PropertyValue ="Crescentv1.Master"

#add property bag in sharepoint 2010/2013
$web.AddProperty($PropertyName,$PropertyValue) #add property bag
Write-host "Created new Property: "$PropertyName

#how to read property bag in sharepoint - query property bag
Write-host "Retrieved $PropertyName Value:" $web.GetProperty($PropertyName)   

#set property bag sharepoint 2010 powershell
$PropertyNewValue ="Crescentv2.Master"
$web.SetProperty($PropertyName, $PropertyNewValue)
Write-host $PropertyName updated with new value:$PropertyNewValue

#Search for a Property
     #access property bag in sharepoint
     write-host Property Found! Value: $web.GetProperty($PropertyName)
#Remove Property from Property Bag
write-host "Property $PropertyName has been deleted!"

#Get all Properties from sharepoint property bag 


The same code can be translated into C# object model to use with Event Receiver, Web Part, etc. – Add new property bag at site collection level: Here is a SharePoint property bag example:

#Get Site collection
SPSite site = new SPSite("https://your-sharepoint-site-url");

//Add new Property bag key and value
//Old Method
//site.Properties.Add("MasterPage", "Crescentv1");

//create property bag in sharepoint
site.AllProperties["MasterPage"] = "Crescentv1.master";
Tips: You can also manage property bag settings using SharePoint Designer!

SharePoint property bag Tools:
There are some utilities to manage SharePoint property bag settings.

  1. SharePoint Property Bag Settings
  2. SharePoint Manager – Can be used as a Property bag editor, viewer as well

SharePoint property bag access denied!
If you don’t have permission to SharePoint objects, you can’t interact with them. E.g. To access/add the SharePoint Farm property bag, you must be a  SharePoint farm administrator. You may get an “Access Denied” Error if not! Use Elevated Privileges to store and retrieve from such objects.

SharePoint property bag limitations: As it’s a Hash Table – you can store data values up to 4 KB in size limit.

Use SharePoint Designer to Manage Property Bag
You can use SharePoint Designer to manipulate items in the property bag! Open the site in SharePoint Designer and click on the “Site Options” button in the ribbon to get property bag editor!

sharepoint designer property bag

Salaudeen Rajack

Salaudeen Rajack - Information Technology Expert with Two-decades of hands-on experience, specializing in SharePoint, PowerShell, Microsoft 365, and related products. He has held various positions including SharePoint Architect, Administrator, Developer and consultant, has helped many organizations to implement and optimize SharePoint solutions. Known for his deep technical expertise, He's passionate about sharing the knowledge and insights to help others, through the real-world articles!

4 thoughts on “Property Bags in SharePoint – Store, Retrieve Custom Configurations

  • I know this is old, but does anyone have the WSP file for the property Bag soultion by Alon Havivi?

  • Propertybag is NOT available at SPSite, so your list nr 3 at the start of your article could be removed.
    There is propertybag at the rootweb, but that is not an spsite object but an spweb object, so your nr 4 in the list already covers that.

  • SPJobDefinition also has a property bag.


Leave a Reply

Your email address will not be published. Required fields are marked *