$SPWeb = Get-SPWeb "https://mydev.company.com"
$spListName = "/Lists/" + "myList"
[Microsoft.SharePoint.SPList]$spList = $SPWeb.GetList(($SPWeb.ServerRelativeUrl.TrimEnd("/") + $spListName))
[Microsoft.SharePoint.SPField] $spField = $spList.Fields["Status"]
$spField.Indexed = $true;
$spField.Update()
$spList.FieldIndexes.Add($spField);
$spList.Update()
$SPWeb.Dispose()
I am using the above code in an attempt to create an index on the Status field of a workflow task list. When I write-host $splist.Title it appears correctly in the output with my list name. When I do the same for $spfield.Title it displays '.Title'
in the output. The script then errors out with " The property 'Indexed' cannot be found on this object." when it hits $spField.Indexed = $true;
Why would this be happening?
Love them all...regardless. - Buddha