Skip to content
This repository has been archived by the owner on Jan 19, 2021. It is now read-only.

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

2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
### Added

### Changed
- Changed fallback scenario for 'Get-PnPFile' where downloading a file created by a user that no longer exists would try a different technique to download the file. This only worked on English environments though. With this fix, it should work for any language. [PR #2852](https://github.com/pnp/PnP-PowerShell/pull/2852)

### Contributors
- Heinrich Ulbricht [heinrich-ulbricht]

## [3.26.2010.0]

Expand Down
3 changes: 2 additions & 1 deletion Commands/Files/GetFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,9 @@ protected override void ExecuteCmdlet()
ClientContext.Load(file, f => f.Author, f => f.Length, f => f.ModifiedBy, f => f.Name, f => f.TimeCreated, f => f.TimeLastModified, f => f.Title);
ClientContext.ExecuteQueryRetry();
}
catch (ServerException e) when (e.Message == "User cannot be found.")
catch (ServerException)
{
// Assume the cause of the exception is that a principal cannot be found and try again without:
// Fallback in case the creator or person having last modified the file no longer exists in the environment such that the file can still be downloaded
ClientContext.Load(file, f => f.Length, f => f.Name, f => f.TimeCreated, f => f.TimeLastModified, f => f.Title);
ClientContext.ExecuteQueryRetry();
Expand Down