Forum Discussion
Mitch Crump
Feb 06, 2020Copper Contributor
Creating a folder in SharePoint when you don't know the full site URL
Working in a demo tenant and every team I spin up has a URL of something like https://tenantname.sharepoint.com/sites/msteams_851011. How can I add folders to these newly created teams when the URL is unpredictable?
I am using this command and everything works but only when I run it after the site creation and have gone and looked up the random alphanumeric URL. In my company's tenant, every Teams site creates a SharePoint URL with the Team name there and not a random string.
Add-PnPFolder -Name NewFolder -Folder /sites/msteams_851011/Documents/CHANNELNAME
1 Reply
- Mitch CrumpCopper Contributor
Mitch Crump I have a foreach loop to return the full URL. I commented out the write-output piece because I just want the URL in the variable.
$Teams = "Team1","Team2" $Teams = (Get-Team |Select GroupId, DisplayName) ForEach ($Team in $Teams) { $SPOURl = (Get-UnifiedGroup -Identity $Team.GroupId | Select -ExpandProperty SharePointSiteURL) #Write-Output "URL for the" $Team.DisplayName "team is" $SPOURL }