Quantcast
Channel: SharePoint 2013 - Development and Programming forum
Viewing all articles
Browse latest Browse all 7589

PowerShell Error while updating a record using Bypasslock method in Powershell

$
0
0

Below is the code:

Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
[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")
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Taxonomy")
$web = Get-SPWeb "http://SharePointdomain/sitess/85bcdccd9204"
#Get Systrem User ID
$sysId = $web.Site.SystemAccount.ID
$sysuser = $web.AllUsers[$sysId]
$token = $sysuser.Token

#Create New Site Object under Token of System Account for the Site Collection
    $newSiteObject = New-Object Microsoft.SharePoint.SPSite($web.Url, $token)
    $newWebObject = $newSiteObject.OpenWeb()

$library = "My Document Library" 

#Create New Site Object under Token of System Account for the Site Collection
#newSiteObject = New-Object Microsoft.SharePoint.SPSite($web, $token)
#w = $newSiteObject.OpenWeb()
$l = $web.Lists[$library] 
$CSVcnt= 0
$items = $list.getItems()  
$listCnt = 0;
Foreach($item in $items){
If($item.ID -eq 127)
 {
   [Microsoft.Office.RecordsManagement.RecordsRepository.Records]::BypassLocks($item, $byPassMethodName)

I am getting the following error:

Execution calling "BypassLocks" with "2" argument(s): value cannot be null.
parameter name: callWithLockingBypassed"
+ CategoryInfo    : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId: ArgumentNullException

How can I fix it please?



Viewing all articles
Browse latest Browse all 7589

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>