I am working with SharePoint online. After a user has finished editing and closed the document, SharePoint still locks it down for that user making us not able to interact with the document as we want. I have checked online and i was able to find a solution that suits my need but only works for on-prem sharepoint.
param ( [string]$url, [string]$list, [string]$item ) $w = get-spweb $url $l = $w.lists[$list] $i = $l.GetItemById($item) $s = New-Object Microsoft.SharePoint.SPSite($w.site.id, $i.File.LockedByUser.UserToken) $w = $s.OpenWeb($w.id) $l = $w.lists[$list] $i = $l.GetItemById($item) $i.File.ReleaseLock($i.File.LockId)
when I modified this for cloud to
param ( [string]$url, [string]$list, [string]$item )
Connect-SPOService -Url https://mysiteurl.com - credential myusername $w = get-sposite -identity $url $l = $w.lists[$list] $i = $l.GetItemById($item) $s = New-Object Microsoft.SharePoint.SPSite($w.site.id, $i.File.LockedByUser.UserToken) $w = $s.OpenWeb($w.id) $l = $w.lists[$list] $i = $l.GetItemById($item) $i.File.ReleaseLock($i.File.LockId)
got an error "cannot index into a null array" at $l = $w.lists[$list]
Am not good with writing powershell script. What am I doing wrong please?