When using Get-PNPRecycleBinItem more than once in a function, sometimes we get a "User not found" error response from the server. When looking at the ULS, the call fails when it is trying to fetch the author property. We are not trying to fetch the Author property, the PNP is fetching this. Once we converted the calls to use CSOM directly, this issue stops occurring. This also seems to only happen when processing a large number of items.
This also happens sometimes when calling Restore-PNPRecycleBinItem.
The code we are using cycles thru URLs to OD4B sites (one drive personal sites) and feeds each one into the Connect-PNPOnline call.
Then the code loops through this-
I believe the 'RetrievalExpressions' might need to be 'DefaultRetrievalExpressions' as this is defined on line 44 and never used. Somehow it is trying to get the author and that seems to gum up the call, even when we are not trying to retrieve that property.
Reporting an Issue
When using Get-PNPRecycleBinItem more than once in a function, sometimes we get a "User not found" error response from the server. When looking at the ULS, the call fails when it is trying to fetch the author property. We are not trying to fetch the Author property, the PNP is fetching this. Once we converted the calls to use CSOM directly, this issue stops occurring. This also seems to only happen when processing a large number of items. This also happens sometimes when calling Restore-PNPRecycleBinItem.
The code we are using cycles thru URLs to OD4B sites (one drive personal sites) and feeds each one into the Connect-PNPOnline call. Then the code loops through this-
Connect-PNPOnline -url https://-my.sharepoint.com -Credentials get-credentials
Write-Host $path
Expected behavior
The commands should succeed to fetch or restore as indicate by the command name.
Actual behavior
Error is returned- "User cannot be found"
Steps to reproduce behavior
Use code like this- Connect-PNPOnline -url https://-my.sharepoint.com -Credentials get-credentials
Write-Host $path
Get-PnPRecycleBinItem | ? DeletedByName -eq 'System Account' | Export-Csv $path try { Get-PnPRecycleBinItem -FirstStage | ? DeletedByName -eq ‘System Account’ | Restore-PnPRecycleBinItem -Force Get-PnPRecycleBinItem | ? DeletedByName -eq 'System Account' | Export-Csv $notrestored } catch { Write-Host $_.Message }
Which version of the PnP-PowerShell Cmdlets are you using?
What is the version of the Cmdlet module you are running?
3.13.1909.0
How did you install the PnP-PowerShell Cmdlets?
I believe this issue is caused by line 49 of this file: https://github.com/SharePoint/PnP-PowerShell/blob/master/Commands/RecycleBin/GetRecycleBinItem.cs
I believe the 'RetrievalExpressions' might need to be 'DefaultRetrievalExpressions' as this is defined on line 44 and never used. Somehow it is trying to get the author and that seems to gum up the call, even when we are not trying to retrieve that property.