I am trying to update a Sharepoint 2010 record using ByPassLock method in Powershell.
I am using below code
[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)
After execution of the script i get below error
Exception calling "BypassLocks" with "2" argument(s): "Attempted to perform an unauthorized operation."
+ [Microsoft.Office.RecordsManagement.RecordsRepository.Records]::BypassLocks <<<< ($item,$modDate)
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : DotNetMethodException
I running this script as administrator and have site collection administrator access on the site. I removed item update part but still it is not working.