I am working with document sets in SharePoint Online. Is there a way with Powershell or C# I can set the values of the document set fields?

Any examples?

It's not clear from what I have seen on the internet.


  • what do you mean by document set fields? do you mean, metadata of Document Set? – SaMolPP Dec 6 at 16:04
  • Yep, document set metadata – Gurdip Sira Dec 6 at 17:04

Assuming you have the document set object $docSet, the metadata of the document set can be updated as below.


The following C# code for your reference.

string targetSiteURL = @"https://xx.sharepoint.com/sites/lz";

var login = "lz@xx.onmicrosoft.com";
var password = "**";
string documentLibraryName = "DocumentLibrary";
string documentSetName = "DdocumentSet1";
string propertyName = "field1";
string updatePropertyValue = "LZ";

var securePassword = new SecureString();
foreach (char c in password)
SharePointOnlineCredentials onlineCredentials = new SharePointOnlineCredentials(login, securePassword);

ClientContext ctx = new ClientContext(targetSiteURL);
ctx.Credentials = onlineCredentials;

Web site = ctx.Web;

List docLib = site.Lists.GetByTitle(documentLibraryName);
CamlQuery caml = new CamlQuery();
caml.ViewXml = "<View><Query><Where><Eq><FieldRef Name='Title'/><Value Type='text'>"+documentSetName+"</Value></Eq></Where></Query></View>"; ;
ListItemCollection items = docLib.GetItems(caml);             
if (items.Count != 0)
    ListItem item = items[0];
    var properties = item.Folder.Properties;
    properties[propertyName] = updatePropertyValue;

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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