Louis-Charles Gagnon

Microsoft Azure, Office 365 and SharePoint Blog

SharePoint 2013 - Fix Lookup column not linking to a list

Sometimes after deployment or data manipulation, a list is left not connected to a list.

With powershell you can fix individual column to update it's lookup list:

 Function Fix-LookupColumn ($webURL, $listName, $columnName, $lookupListName)
 {
     #Get web, list and column objects
     $web = Get-SPWeb $webURL
     $list = $web.Lists[$listName]
     $column = $list.Fields[$columnName]
     $lookupList = $web.Lists[$lookupListName]
 
     #Change schema XML on the lookup column
     $column.SchemaXml = $column.SchemaXml.Replace($column.LookupWebId.ToString(), $web.ID.ToString())
     $column.SchemaXml = $column.SchemaXml.Replace($column.LookupList.ToString(), $lookupList.ID.ToString())
     $column.Update()
 
     #Write confirmation to console and dispose of web object
     write-host "Column" $column.Title "in list" $list.Title "updated to lookup list" $lookupList.Title "in site" $web.Url
     $web.Dispose()
 }


In order to use this function, simply call the following:

Fix-LookupColumn -webURL <URL> -listName "<List name containing the lookup column>" -columnName "<Lookup column name>" -lookupListName "<List used by the lookup column>"

For example:

Fix-LookupColumn -webURL http://mysite/site -listName "Clients" -columnName "Company" -lookupListName "Company"

SharePoint 2013 - Search service stuck and/or paused for (Paused by System, Index Reset, External Request)

Sometimes the search services gets stuck, following an index reset or a problem with the search component.
When Search service application shows crawl status as “Paused by system” or “External Request”, it can be fixed below:

Display search component status:
$ssa = Get-SPEnterpriseSearchServiceApplication
get-spenterprisesearchstatus -SearchApplication $ssa -Detailed -Text

Resume search component:

(Optional) If not running SharePoint Management:

Add-PSSnappin "Microsoft.SharePoint.PowerShell"

Then:

$ssa = Get-SPEnterpriseSearchServiceApplication
Resume-SPEnterpriseSearchServiceApplication $ssa

Force a index reset (if stuck):

Make sure to reset the Search Host Controller service and timer service before running theses commands.

(Optional) If not running SharePoint Management:

Add-PSSnappin "Microsoft.SharePoint.PowerShell"

Then:

$ssa = Get-SPEnterpriseSearchServiceApplication
$disableAlerts = $true
$ignoreUnreachableServer = $true
$ssa.reset($disableAlerts, $ignoreUnreachableServer)