Forum Discussion
Mitch Crump
Feb 11, 2020Copper Contributor
Get SharePoint Site URL of an individual Microsoft Team
I found the below code online. I want to use the same concept but only return one SP site URL so I can use the URL to create a folder in that Team. $Teams = (Get-Team |Select GroupId, DisplayNa...
Tom__B
Mar 21, 2024Copper Contributor
With Graph Explorer, I'm able to request the following endpoint:
GET https://graph.microsoft.com/v1.0/groups/{groupId}/sites/root?$select=name,webUrl
Which return the requested information:
{
"@odata.context": "https://graph.microsoft.com/v1.0/$metadata#sites(name,webUrl)/$entity",
"name": "MYTEAMSITE",
"webUrl": "https://<tenant>.sharepoint.com/sites/MYTEAMSITE"
}
But the translated PowerShell query doesn't work for me, it asks for a $SiteId parameter, but I don't know how to get it for a Team site:
Import-Module Microsoft.Graph.Sites
Get-MgGroupSite -GroupId $groupId -SiteId $siteId -Property "name,webUrl"
- Tom__BMar 22, 2024Copper Contributor
Instead of using a couple of PowerShell Modules (ExchangeOnlineManagement, MicrosoftTeams, Sharepoint online management shell), I managed to do what I wanted (Updating MailNickname and SharePointSiteURL of aTeams site) with PnP.Powershell module.
With this module, to get a Teams Site URL, use the following code:
Get-PnPMicrosoft365Group -Identity $GroupId -IncludeSiteUrl | Select-Object -ExpandProperty SiteUrl