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.