Remove Enforce Unique Values check box from all fields in all lists

Olga Loseva -

$SPWeb = Get-SPWeb "Your Lanteria system URL"
$lists = $spweb.lists
$fa = New-Object System.Collections.ArrayList
$fa.Clear()
foreach ($list in $lists)
{
 foreach ($f in $list.Fields)
 {
  if ($f.CanBeDeleted -eq $True)
  {
   if ($f.EnforceUniqueValues -eq $True)
   {
    echo "--" $list.Name "--"
    echo "----" $f.Name "-----"
    $fa.add($f)
   }
  }
 }
}
$f_count = $fa.count
for ($x = $f_count-1; $x -ge 0; $x--)
{
 $field = $fa[$x]
 $field.EnforceUniqueValues = $False
 $field.Update()
}

 

Have more questions? Submit a request

Comments

Powered by Zendesk