Please refer to the original question.
At this point my conclusion is that the problem exists somewhere within .Net Core or in this unnamed 3rd party web app. From my testing, "normal IIS/.Net" works fine. I am not familiar enough with .Net Core to be able to recreate this problem. I also don't know how this 3rd party app calls Powershell. I would assume that it is shelling out Powershell.exe, but for all I know it could be doing something else, like calling some flavor of pwsh.exe. (To align with the cross platform nature of .Net Core.)
Bojan, I'm sorry, but it is virtually impossible for forum users to troubleshoot based on "An error has occurred which PowerShell cannot handle". We would need to know what that error is.
Since you are using a 3rd party app, I would suggest that you work with their tech support team to troubleshoot the problem. Have them enable whatever troubleshooting tools that are available to them to trace the Powershell call. If nothing else, ask them how they implemented calling Powershell.
Share with them the ASPX page that I wrote for you and ask them why that page works, but their application fails.