How can I Enforce unique values: in powershell? Client-side as well not server-side Here is the code that I have :

$ListInfo = New-Object Microsoft.SharePoint.Client.ListCreationInformation
$ListInfo.Title = $ListTitle
$ListInfo.TemplateType = "100"
$myList = $web.Lists.Add($ListInfo)
$myList.Description = $ListTitle
$myList.Fields.AddFieldAsXml("<Field Type='Number' DisplayName='SortOrder' />",$true,[Microsoft.SharePoint.Client.AddFieldOptions]::AddFieldToDefaultView)


just need to make it a unique field

  • What do you mean by "unique"?
    – Brandon C.
    Jun 30, 2014 at 9:23
  • Enforcing unique values
    – bimbob
    Jun 30, 2014 at 9:26
  • So you want each field to have a unique value not found anywhere else in the list?
    – Brandon C.
    Jun 30, 2014 at 9:30
  • in the column, say if I was creating the column on my sharepoint I would click enforce unique values
    – bimbob
    Jun 30, 2014 at 9:32
  • What my question is, is how do you want this script to run? If you force unique values, what happens if a similar value is added? What is it exactly that the script should do?
    – Brandon C.
    Jun 30, 2014 at 9:41

1 Answer 1



Here is a link that should help you better understand what you need to do. I suppose just writing

$Fields.Indexed = true;
$Fields.EnforceUniqueValues = true; 

would suffice. I haven't worked with this, but the example seems like you have to do this on a list object, not a listcollection object.

EDIT: It seems, to this day, I cannot tell the difference between Acronym's (even had to look that word up to remember it). This answer applies to SSOM and not CSOM. Please see comments for more information.

$fieldname.indexed = $true; 
$fieldname.EnforcedUniqueValues = $true

Thanks to bimbob for supplying the CSOM equivilant.

  • The link you have provided is not correct, the OP is asking about CSOM, not SSOM. Jun 30, 2014 at 10:00
  • Another point, $fields is a field collection (!), you could specify EnforceUniqueValues for a field, not a field collection Jun 30, 2014 at 10:03
  • I understood the link provided and for me he supplied a sufficient and correct answer. Understand that a few tweaks could be made to make it a better answer
    – bimbob
    Jun 30, 2014 at 10:03
  • I would recommend to update the answer otherwise it does not seem correct Jun 30, 2014 at 10:04
  • 1
    Updated. Sorry for the confusion!
    – Brandon C.
    Jun 30, 2014 at 10:15

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.