pnp / PnP-PowerShell

SharePoint PnP PowerShell CmdLets
https://pnp.github.io/powershell
Other
987 stars 665 forks source link

Get-PnPFile fails with "User cannot be found" if Author is unresolveable #1854

Closed JaredRic-MSFT closed 4 years ago

JaredRic-MSFT commented 5 years ago

Notice: many issues / bugs reported are actually related to the PnP Core Library which is used behind the scenes. Consider carefully where to report an issue:

  1. Are you using Apply-SPOProvisioningTemplate or Get-SPOProvisioningTemplate? The issue is most likely related to the Provisioning Engine. The Provisioning engine is not located in the PowerShell repo. Please report the issue here: https://github.com/officedev/PnP-Sites-Core/issues.
  2. Is the issue related to the cmdlet itself, its parameters, the syntax, or do you suspect it is the code of the cmdlet that is causing the issue? Then please continue reporting the issue in this repo.
  3. If you think that the functionality might be related to the underlying libraries that the cmdlet is calling (We realize that that might be difficult to determine), please first double check the code of the cmdlet, which can be found here: https://github.com/OfficeDev/PnP-PowerShell/tree/master/Commands. If related to the cmdlet, continue reporting the issue here, otherwise report the issue at https://github.com/officedev/PnP-Sites-Core/issues

Reporting an Issue or Missing Feature

Please confirm what it is that your reporting

When running Get-PnPFile against a file where the Author property is unresolveable (user removed from AAD & User Information List) it fails to return the file due to code in this cmdlet which auto populates the author field.

Expected behavior

Please describe what output you expect to see from PnP-PowerShell Cmdlets

When calling Get-PnPFile it should load the file even if the author field is unresolveable.

Actual behavior

Please describe what you see instead. Please provide samples of HTML output or screenshots

When calling Get-PnPFile it fails with the following error: Get-PnPFile : User cannot be found.

Steps to reproduce behavior

Please include complete code samples in-line or linked from gists

  1. Add a user in AAD.
  2. Have the user create a document on a site collection.
  3. Remove the user from AAD (including in Deleted users)
  4. Remove the user from the User Information List (_layouts/15/people.aspx?MembershipGroupId=0)
  5. Run Get-PnPFile -url "URL to File"

Which version of the PnP-PowerShell Cmdlets are you using?

What is the version of the Cmdlet module you are running?

(you can retrieve this by executing Get-Module -Name *pnppowershell* -ListAvailable)

3.5.1901.0

How did you install the PnP-PowerShell Cmdlets?

Ian-Sanders commented 5 years ago

Experiencing same behaviour. Cmdlet fails with "User cannot be found" when Author is unresolvable.

SharePointPnPPowerShellOnline 3.7.1903.0 Installed through the PowerShell Gallery with Install-Module

peterdeleu commented 5 years ago

Same here

AlexSen commented 4 years ago

Same here

KoenZomers commented 4 years ago

Thanks for providing the clear repro steps. This issue has been fixed and will be released with the March 2020 release. PR #2504 . Closing this issue. In case you're still experiencing issues with the March 2020 release, feel free to reopen this issue.

erwinvanhunen commented 4 years ago

Hi @JaredRic-MSFT :

Can you please create an issue on https://sharepoint.uservoice.com/forums/329220-sharepoint-dev-platform too? We will merge this fix, but in effect it's a strange behavior of SharePoint. A developer cannot know up front if a user is still available or not. If the user is removed from the Site Users list this error occurs, and effectively the SharePoint CSOM API should return a null value instead of throwing an exception.

Thanks,

/Erwin

ghost commented 4 years ago

getting the same error with todays SharePointPnPPowerShellOnline 3.21.2005.2

KoenZomers commented 4 years ago

@Bjorn80 It's working fine here. Just gave it another test. Does your situation exactly match the steps outlined above?