Question

I'm trying to move my site from a server to another.

I exported my site using Export-SPWeb, moved the data to destination server and ran the function below: (Taken from here.)

function import-spweb($sourceFile,$url,$retainObjectIdentity=$false,$includeSecurity=$true)
{
    [void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Deployment")
    $import = new-object Microsoft.SharePoint.Deployment.SPImport  
    $settings = new-object Microsoft.SharePoint.Deployment.SPImportSettings 
    $settings.FileLocation = [System.IO.Path]::GetDirectoryName($sourceFile)
    $settings.BaseFileName = [System.IO.Path]::GetFileName($sourceFile)
    $settings.SiteUrl = $url
    $settings.WebUrl = $url
    $settings.RetainObjectIdentity = $retainObjectIdentity

    if($includeSecurity){$settings.IncludeSecurity = [Microsoft.SharePoint.Deployment.SPIncludeSecurity]::All}
        else{$settings.IncludeSecurity = [Microsoft.SharePoint.Deployment.SPIncludeSecurity]::None}
    $settings.UpdateVersions = [Microsoft.SharePoint.Deployment.SPUpdateVersions]::Append
    $settings.UserInfoDateTime = [Microsoft.SharePoint.Deployment.SPImportUserInfoDateTimeOption]::ImportAll      

    $import.Add_ProgressUpdated({write-Progress "Importing" ("Objects: " + $_.ObjectsProcessed )  -perc -1})
    $import.Settings = $settings
    $import.Run()   
}

Now, I did this before but somehow it doesn't work anymore and gives the error below:

Exception calling "Run" with "0" argument(s): "Object reference not set to an instance of an object."

I create destination site collection without a template by selecting "Select Later".

Any help would be great.

Was it helpful?

Solution

Have you considered doing this using a DB-Attach approach instead?

If you are using SP2007 you have some stsadm commands at your disposal, in SP2010 there are similar cmdlets in PowerShell.

Here is a blog post where I extract my sites from an existing database and merge them into another. TechNet samples on stsadm command.

On SP2010 there are also several approaches. Here is an article on moving content databases using PowerShell.

OTHER TIPS

Interestingly, using this tool solved my problem. I thought the program would be using the same methods. Any ideas?

Verify that the user running the script has permission on the database.

Verify that the same features are enabled at the source and destination site collection/site.

Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top