Assembly Problem with additional module

Product: PowerShell Universal
Version: 2.1.2

I want to create an API which works as a Sharepoint File Upload Gateway. The following code works fine directly executed from PWSH 7:

import-module pnp.powershell
$cred=get-secret "MyM365-Credential"
$SharepointURL = "https://company.sharepoint.com/sites/Site123"
$OutPath = "C:\temp\demo.txt"
Connect-PnPOnline $SharepointURL -Credentials $cred 
Add-PnPFile -Folder "Shared%20Documents/" -Path $OutPath

If I run it from an API endpoint it has problems with the JWT assembly version:

Could not load file or assembly 'System.IdentityModel.Tokens.Jwt, Version=6.11.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. Could not find or load a specific file. (0x80131621)

So I tried to offload the code into a PSU script, same code, dedicated environment which points to the pwsh.exe. Now it has problems with another assembly:

Could not load type 'Microsoft.Extensions.Logging.Abstractions.Internal.NullScope' from assembly 'Microsoft.Extensions.Logging.Abstractions, Version=5.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'

Any hint how to handle such problems or how to track down the culprit?

-Sascha aka callidus2000

Found a workaround for cases in which the environment has already loaded incompatible assemblies:
Powershell Remoting to the local computer.

Not the direct approach but working in this caseā€¦

This should be resolved in 2.3. We were unintentionally loading a bunch of assemblies that were causing conflicts with modules loaded into PSU.

Nice to know, waiting for the release and test it then.

Cool. Nightly builds are also available here if you would like to see if it resolves your issue: https://imsreleases.z19.web.core.windows.net/

Were you ever able to use the PNP.PowerShell module in PS7 PSU environment?