@AHMAD ABDELHAFEZ ELAGAMY -
There doesn't seem to be any way available in JQuery/Javascript to check if the SharePoint site is opened from MS teams or not
Using below powershell command you can get the SharePoint site URL and then you can add your custom logic to check if the URL is available in that list or not.
Get-UnifiedGroup –Filter {ResourceProvisioningOptions -eq "Team"} |
Select DisplayName,SharePointSiteUrl |
Export-CSV ./TeamsSPOUrl.csv -NoTypeInformation
When a team is created, a Microsoft 365 group is created to manage team membership. So, we can use Get-UnifiedGroup cmdlet with ResourceProvisioningOptions filter to retrieve the SharePoint URLs for Teams-enabled Microsoft 365 groups.
The below given code exports Teams and their associated SharePoint site URL to TeamsSPOUrl.csv file.
Get-UnifiedGroup –Filter {ResourceProvisioningOptions -eq "Team"} |
Select DisplayName,SharePointSiteUrl |
Export-CSV ./TeamsSPOUrl.csv -NoTypeInformation
To run the Get-UnifiedGroup cmdlet, you need to connect to Exchange Online PowerShell module.
Ref Doc: https://learn.microsoft.com/en-us/powershell/module/exchange/get-unifiedgroup?view=exchange-ps
Thanks,
Nivedipa
------------------------------------------------------------------------------------------------------------------------
If the response is helpful, please click "Mark as Best Response" and like it. You can share your feedback via Microsoft Teams Developer Feedback link. Click here to escalate.