pnp / PnP-PowerShell

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

Fixing how Get-PnPFile handles removed principals in non-English environments #2852

Closed heinrich-ulbricht closed 3 years ago

heinrich-ulbricht commented 4 years ago

Type

Related Issues?

N/A

What is in this Pull Request ?

This PR allows to use Get-PnPFile for files where the author or modifier principal does not exist anymore in the environment. The PR removes the error message check that relies on an English environment. Unfortunately the error message can come back localized so this doesn't really work.

fyi @KoenZomers

heinrich-ulbricht commented 4 years ago

Ideally this would check the ServerErrorCode instead of the error message (or nothing like in this PR). But I'm not sure how reliable this would be - see the related question on Twitter: https://twitter.com/h_ulbricht/status/1295355161469231105?s=20

KoenZomers commented 3 years ago

Good point here @heinrich-ulbricht. Didn't think about the lovely localized error messages. I'm not sure myself how reliable the error codes will be. As the exception goes to a fallback scenario effectively still trying to perform the same operation, just without requesting the author field, I think we're okay with the approach you're suggesting here. If the exception would be thrown for other reasons and the same fallback doesn't fix it, it will still throw an exception in the catch and do the same as it would do today.

erwinvanhunen commented 3 years ago

Thanks @heinrich-ulbricht !