Ok.. Spent hours on this now.
Managed to enable Failed Request Tracing in IIS for error 500 and what I can find in all the data collected, related to my issue is this:
<EventData>
<Data Name="ContextId">{80000014-0000-FD00-B63F-84710C7967BB}</Data>
<Data Name="ModuleName">FastCgiModule</Data>
<Data Name="Data1">FASTCGI_SETSTATUS</Data>
<Data Name="Data2">500 Internal Server Error</Data>
<Data Name="ErrorCode">0</Data>
</EventData>
So, I checked the handler mappings for FastCGI in IIS and find nothing strange, also checked permissions on the actual php files.
I then tried change PHP version fron 8.1.11 to 8.0.24 and the issue is gone.
My next question is: Will the Oauth2 plugin for mailfetching work with php 8.0.24?