对象引用未在spimport.run()中设置错误
-
16-10-2019 - |
题
我正在尝试将我的网站从服务器移至另一台服务器。
我使用导出SPWEB导出了我的网站,将数据移至目标服务器并运行以下功能:(从 这里.)
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()
}
现在,我以前这样做了,但是以某种方式不再起作用,并给出以下错误:
使用“ 0”参数调用“运行”:“对象引用未设置为对象的实例。”
我通过选择“稍后选择”而无需模板创建目标站点集合。
任何帮助都会很棒。
其他提示
有趣的是,使用 这个工具 解决了我的问题。我认为该程序将使用相同的方法。有任何想法吗?
验证运行脚本的用户是否已在数据库上有权限。
验证在源和目标站点收集/站点上启用了相同的功能。