Tuesday, July 31, 2018

SharePoint TIP: working with the farm property bag


Farm Property Bag

List farm properties$farm = Get-SPFarm
$farm.Properties.GetEnumerator() | Sort Name | fl -Auto
or
(Get-SPFarm).GetEnumerator() | Sort Name | fl -Auto
Add a farm property$farm=Get-SPFarm
$farm.Properties.Add("[name]", "[value]")
$farm.Update()
Set a farm property$farm.Properties["[name]"] = $value
$farm.Update()
Remove a farm property$farm.Properties.Remove("[name]")
$farm.Update()

References

  • Properties are stored in Hash-Table (Key-Value) format.
  • Not case-sensitive.
  • Same approach is used at the web application, site collection, web and list levels.  Each of these has a "Properties" collection.  For web application properties, you would use a web application object, for site collections, get an instance of the site collection object, and so on.
  • I have found that some SharePoint solution (e.g., farm solution) providers add properties to the farm properties bag for internal sharing of licensing information.
  • Properties must be added as key-value pairs.

No comments: