This script will list all members and owners per team.
When you add -savedcred:$true it will save a credential file locally, which will give you automated access using that same account to your tenant.
It won't save your credential plane text, it will use credential vault, which should be perfectly secure.
When using MFA on that service-account, make sure you use an app password.

It also list the object ID's of both the users and the teams, which means you can use the exported CSV for other scripts (like removing a user from all teams).

The following columns are shown: