Steps
Start your Windows PowerShell on your computer.
Right click and select run as an administrator option.
Paste the script given below on PowerShell Window and click the enter button.
Check your SharePoint site feature, which will be activated successfully.
- Function AddIndex ()
- {
- Param ($listname,$InternalFieldName)
-
- try
- {
- Write-Host "Retriving the field $InternalFldName";
-
- $fieldToIndex =$list.Fields.GetFieldByInternalName($InternalFldName);
-
- Write-Host $fieldToIndex has been found";
-
- try
- {
- $index= $list.FieldIndexes.Item($fieldToIndex.Id)
- Write-Host $fieldToIndex is already indexed"
- }
- catch
- {
- $fldToIndex.Indexed = $true;
- $list.FieldIndexes.Add($fldToIndex);
- Write-Output ("The field {0} has been indexed" -f $fldToIndex.Title);
- }
-
- }
- catch
- {
- $error[0]
- }
-
- }