I am using the following SharePoint commands to migrate a list between site collections. The list has lookup columns.

Export-SPWeb -Identity "http://example.com/sites/live/cs" -path "C:\myfolder\mylist.cmp"  -ItemUrl "/sites/live/cs/Lists/mylist"

Import-SPWeb -Identity "http://example.com/sites/portal" -path "C:\myfolder\mylist.cmp"

I am getting warnings like this:

[8/17/2016 12:09:20 PM] Warning: Unable to find a lookup list /sites/portal/cs/Lists/childListName. The list is not part of the exported package and does not exist in the destination site collection.

I have already created childListName in the destination site collection with the same list name. But it doesn't help.

Is there any way to tell Export-SPWeb or Import-SPWeb how to map the dependent list properly between site collections?


The reason the lookups do not work when you have re-imported is that the references to the list and web are still set to that of the the previous web, set in the schema upon creation. Thus to change these you must interogate the schema and set these values relative to the new location. See my powershell below;

$webURL = http://MyNewSite
$web = Get-SPWeb $webURL
$list = $web.Lists["My List"]  // Note this is the list with the configured lookup column
$field = $list.Field["My Lookup Field"]
// At this point you will want to interogate the value of $field.SchemaXml
// The below is an example based on my own testing
$schemaXml = '<FieldType="Lookup" DisplayName="Georges Lookup" Required="FALSE" EnforceUniqueValues="FALSE" List="{$web.ID}" ShowField="Title" UnlimitedLengthInDocumentLibrary="FALSE" RelationshipDeleteBehavior="None" ID="{8765e7d6-5c35-4df5-bc25-90b9707e4be6}" SourceID="{$list.ID}" StaticName="Lookup" Name="Lookup" ColName="int1" RowOrdinal="0" Group="" Version="1"/>'
$field.SchemaXml = $schemaXml

To summarise, replace the List value with the schema with the $list.ID, and the SourceID with the $web.ID.

Hope this helps

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.