Is there any way (C# or PowerShell) by which we can get SharePoint Site URL associated with Microsoft Teams ? If anyone has code/script for the same , kindly share . Any kind of suggestion will be helpful .
We came across your question while researching a similar problem. To my knowledge there is no simple way of doing this.
In the end we decided on a combination of the Microsoft Graph API to retrieve all of the Microsoft Team IDs and then we used the DO_NOT_DELETE_SPLIST_TENANTADMIN_AGGREGATED_SITECOLLECTIONS list from the SharePoint admin center to connect the Team to its corresponding site collection. This funny named list is actually used in the new SharePoint admin center and it has some useful information. Unfortunately it does not have a field that would say if it was a Microsoft Teams site, but thankfully it does have a field that tells you if you are dealing with an Office 365 group.
We did try other more direct solutions like the Exchange Online Remote Powershell but we either could not retrieve the site URL for private Teams, or we could not determine if an Office 365 Group even was a team.
I wrote a blog post about this matter and it describes in more detail how the URLs can be retrieved.
Hopefully it helps somebody in the future.