Add to Office365 PropertyBag (PowerShell)

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 :

How to read all property bags in a SharePoint Online Site Collection

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.   


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s