I am trying to set some property bag values in SharePoint Online, specifically around SharePoint Designer access. The code below runs without error, but I do not see the propertybag value being updated in /_layouts/15/SharePointDesignerSettings.aspx. Is it not possible to update PropertyBag values in SharePoint Online?

$SiteUrl = "https://tenant.sharepoint.com/teams/eric"
$context = New-Object Microsoft.SharePoint.Client.ClientContext($SiteUrl)
$context.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($credential.UserName, $credential.Password)
$web = $context.Site.RootWeb
$props =  $web.AllProperties
$props.FieldValues["allowdesigner"] = 0

Works for me with a couple small changes. Instead of manipulating the FieldValues object, just manipulate the AllProperties object directly. Also, set the value to a string, not an int:

web.AllProperties["allowdesigner"] = "0";

Here's the full helper method I use:

public static void AddWebProperty(ClientContext ctx, string propertyName, string propertyValue)
    Web web = ctx.Web;

    web.AllProperties[propertyName] = propertyValue;
| improve this answer | |
  • I knew I was effing something up somewhere. Adapting this to the existing PowerShell I had then set the desired properties. – Eric Alexander Feb 16 '16 at 14:34
  • 3
    You don't need to load properties. It's just unnecessary traffic. – dstarkowski Feb 16 '16 at 14:35
  • @dstarkowski I wasn't sure, and never bothered to verify. I've edited the post to remove that. Thank you. – Derek Gusoff Feb 16 '16 at 14:49

Derek's answer solves problem for property bag in general, but there's also Site.AllowDesigner property you could use for your specific case.

| improve this answer | |

PFB script to update in SP online to disable all controls in Designer settings in Site Collection

$url="SC URL"

$ctx = New-Object Microsoft.SharePoint.Client.ClientContext($url) 

$username= "Username";
$password=ConvertTo-SecureString 'Password' -AsPlainText -Force;

$credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($username , $password);

$ctx.Credentials = $credentials ;







| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.