【发布时间】:2014-05-22 12:40:05
【问题描述】:
我正在尝试使用 Powershell 中的 ByPassLock 方法更新 Sharepoint 2010 记录。
我正在使用下面的代码
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint") | Out-Null
[void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.Office.RecordsManagement.RecordsRepository.Records")
[void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Publishing")
$modDate = {
param(
[Microsoft.SharePoint.SPListItem]$a
)
$a["Title"] = "NewTitle"
$a.SystemUpdate($true)
}
$web = Get-SPWeb "http://mySiteCollection/"
$item = $web.Lists["Dokument"].GetItemById(10)
[Microsoft.Office.RecordsManagement.RecordsRepository.Records]::BypassLocks($item,$modDate)
执行脚本后出现以下错误
使用“2”个参数调用“BypassLocks”的异常:“尝试执行未经授权的操作。”
+ [Microsoft.Office.RecordsManagement.RecordsRepository.Records]::BypassLocks
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : DotNetMethodException
我以管理员身份运行此脚本,并在网站上拥有网站集管理员访问权限。我删除了项目更新部分,但仍然无法正常工作。
有人可以帮我解决这个问题吗
【问题讨论】:
标签: powershell sharepoint