1

I am not sure what is wrong with my code to retrieve the list of the events exist in my online sharepoint calendar without the deleted events:

 Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.dll"

 Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.Runtime.dll"

 $Creds = New-Object 
 Microsoft.SharePoint.Client.SharePointOnlineCredentials($Username,$Pass)

 $Context = New-Object Microsoft.SharePoint.Client.ClientContext($URI)

 $Creds = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Username,$Pass)

 $Context.Credentials = $Creds
 $List = $Context.Web.Lists.GetByTitle($ListTitle)
 $Context.Load($Context.Web.Lists)
 $Context.ExecuteQuery()
 $context.Load($List)
 $context.ExecuteQuery()
 $query = [Microsoft.SharePoint.Client.CamlQuery]::CreateAllItemsQuery(1000)

 $items = [Microsoft.SharePoint.Client.ListItemCollection]$List.GetItems($query)

 $context.Load($Items)
 $context.ExecuteQuery()
 Foreach ($Item in $Items){ $Item.FieldValues }

all the $Items I am getting are including the items that I have already delete from the web (them are not appearing anymore).

These anyone can see what I am doing wrong and how can I fix it to eliminate the deleted events? Need to be solved only thru PowerShell.

Thanks Tal

  • script looks good. Can you check recycle bin? Thats odd what is going on, but check it. – Zdeněk Vinduška Jan 28 at 9:03
  • How I can check in recycle bin from PowerShell? – Tal Jan 28 at 11:14
  • Look simply in UI Site Settings on Root SA and Recycle bin – Zdeněk Vinduška Jan 28 at 12:53
  • This is not my answer as all is need to be done automatically then it is need to be done from PowerShell, any other suggestion? Thanks – Tal Jan 29 at 6:21
  • yay, I only want you to check if there is something, because you SHOULD NOT get deleted items from library or list, so the items must be still in library/list but not in the view? – Zdeněk Vinduška Jan 29 at 7:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.