I'm currently using SPExportSettings
and SPImportSettings
to migrate some content from an old 2007 environment.
The below code is all working fine, as designed, but not as I'd like. My document libraries need to retain their internal ID's after the migration.
Because I have RetainObjectIdentity = $true
on the import, that seems to keep the libraries URL structure in tact, so it ignores my $_destWebUrl
, for where to import to (they originate in the rootweb so they are being deployed to the new rootweb).
If I set RetainObjectIdentity = $false
, then it's imported to the subsite as I'd like, but the ID's are all gone.
Desired Source: http://sharepoint/MigrationSource
Desired Target: http://sharepoint/MigrationTarget/SUBSITE
Relevant export code:
$settings = New-Object Microsoft.SharePoint.Deployment.SPExportSettings
$settings.SiteUrl = $_sourceSite
$settings.ExportMethod = [Microsoft.SharePoint.Deployment.SPExportMethodType]::ExportAll
$settings.IncludeSecurity = [Microsoft.SharePoint.Deployment.SPIncludeSecurity]::All
$settings.FileLocation = $_fileLocation
$settings.FileCompression = $true
$settings.BaseFileName = $_fileName
$settings.OverwriteExistingDataFile = $true
$settings.IncludeVersions = [Microsoft.SharePoint.Deployment.SPIncludeVersions]::All
....snip
foreach ($obj in $_exportObjs)
{
# Create a new SPExportObject which contains the content to be exported
$exportObject = New-Object Microsoft.SharePoint.Deployment.SPExportObject
$exportObject.IncludeDescendants = [Microsoft.SharePoint.Deployment.SPIncludeDescendants]::All
$exportObject.Type = [Microsoft.SharePoint.Deployment.SPDeploymentObjectType]::List
$exportObject.Id = $_spweb.Lists.TryGetList($obj).ID
$settings.ExportObjects.Add($exportObject)
Write-Host `t`t$obj" has been added"
}
And import code:
$settings = New-Object Microsoft.SharePoint.Deployment.SPImportSettings
$settings.SiteUrl = $_destSiteUrl
$settings.WebUrl = $_destWebUrl
$settings.FileLocation = $_fileLocation
$settings.BaseFileName = $_fileName
$settings.FileCompression = $true
$settings.RetainObjectIdentity = $true
$settings.UserInfoDateTime = [Microsoft.SharePoint.Deployment.SPImportUserInfoDateTimeOption]::ImportAll
If there is no way around this issue, is there a way to move a document library, within a site collection, while retaining all internal ID's?