Been fiddling with some script to ADD a value to the PropertyBag for a SharePoint site within Office365.
There’s a great post (and script) on the Microsoft site – for READING all properties :
But, for adding a new key, I had to fiddle & find an answer.
This post also – mentions the issue with “persisting” values :
Add and Retrieve property bag by CSOM (thanks !!)
NB. This code (PowerShell) will only ADD a key/value – if not already in place. (You’ll need to change slightly – to UPDATE the value)
$rootWeb = $spoCtx.Web
$allProps = $rootWeb.AllProperties;
# DOESN’T WORK !!
# $allProps.FieldValues.Add(‘KEY’, $value);
$rootWeb.AllProperties[‘KEY’] = $value;
That’s not TOO tricky in the end – just needed some fiddley syntax to make it work – especially the POWERSHELL bit…
Hope that helps you – it was a battle for me.