Get SharePoint Site URL of an individual Microsoft Team

%3CLINGO-SUB%20id%3D%22lingo-sub-1165656%22%20slang%3D%22en-US%22%3EGet%20SharePoint%20Site%20URL%20of%20an%20individual%20Microsoft%20Team%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1165656%22%20slang%3D%22en-US%22%3E%3CP%3EI%20found%20the%20%3CA%20href%3D%22https%3A%2F%2Foffice365itpros.com%2F2019%2F03%2F27%2Ffinding-sharepoint-urls-teams%2F%22%20target%3D%22_self%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3Ebelow%20code%20online%3C%2FA%3E.%20I%20want%20to%20use%20the%20same%20concept%20but%20only%20return%20one%20SP%20site%20URL%20so%20I%20can%20use%20the%20URL%20to%20create%20a%20folder%20in%20that%20Team.%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-markup%22%3E%3CCODE%3E%24Teams%20%3D%20(Get-Team%20%7CSelect%20GroupId%2C%20DisplayName)%0AForEach%20(%24T%20in%20%24Teams)%20%7B%0A%20%20%20%24SPOURl%20%3D%20(Get-UnifiedGroup%20-Identity%20%24T.GroupId%20%7C%20Select%20-ExpandProperty%20SharePointSiteURL)%0A%20%20%20Write-Host%20%22URL%20for%20the%22%20%24T.DisplayName%20%22team%20is%22%20%24SPOURL%20%7D%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3CBR%20%2F%3EIt%20would%20be%20easiest%20to%20start%20with%20getting%20the%20Team%20by%20displayname%20then%20taking%20the%20group%20ID%20and%20using%20that.%20All%20the%20individual%20versions%20of%20-expandproperty%20SharePointURL%20have%20not%20worked%20for%20me%20yet.%20Any%20advice%3F%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-markup%22%3E%3CCODE%3EGet-Team%20-DisplayName%20%24Team%20%7C%20Select%20GroupId%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1165656%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3ESharePoint%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1165935%22%20slang%3D%22en-US%22%3ERe%3A%20Get%20SharePoint%20Site%20URL%20of%20an%20individual%20Microsoft%20Team%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1165935%22%20slang%3D%22en-US%22%3E%3CP%3EMight%20help%20if%20you%20give%20us%20the%20exact%20samples%20you%20are%20running%2C%20I%20don't%20see%20any%20problem%20with%20the%20above.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1166547%22%20slang%3D%22en-US%22%3ERe%3A%20Get%20SharePoint%20Site%20URL%20of%20an%20individual%20Microsoft%20Team%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1166547%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F58%22%20target%3D%22_blank%22%3E%40Vasil%20Michev%3C%2FA%3E%26nbsp%3BI%20am%20trying%20to%20do%20something%20like%20the%20two%20examples%20below%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-markup%22%3E%3CCODE%3EGet-Team%20-DisplayName%20%24Team%20%7C%20Select%20GroupId%0A%24SPOURL%20%3D%20(Get-Team%20-Identity%20%24Team.GroupId%20%7C%20Select%20-ExpandProperty%20SharePointSiteURL)%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-markup%22%3E%3CCODE%3EGet-Team%20-DisplayName%20%24Team%20%7C%20Select%20GroupId%0A%24SPOURL%20%3D%20(Get-PnpSite%20-Identity%20%24Team.GroupId%20%7C%20Select%20-ExpandProperty%20SharePointSiteURL)%3C%2FCODE%3E%3C%2FPRE%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1166748%22%20slang%3D%22en-US%22%3ERe%3A%20Get%20SharePoint%20Site%20URL%20of%20an%20individual%20Microsoft%20Team%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1166748%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F163074%22%20target%3D%22_blank%22%3E%40Mitch%20Crump%3C%2FA%3E%26nbsp%3BI%20don't%20want%20to%20use%20UnifiedGroup%20because%20I%20only%20want%20a%20singular%20URL%20but%20now%20Get-UnifiedGroup%20is%20not%20working%20for%20me%20and%20I%20can't%20find%20the%20required%20module%20to%20install%20for%20it.%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-markup%22%3E%3CCODE%3EPS%20C%3A%5CWINDOWS%5Csystem32%26gt%3B%20Find-Module%20-Includes%20Cmdlet%20Get-UnifiedGroup%0APackageManagement%5CFind-Package%20%3A%20No%20match%20was%20found%20for%20the%20specified%20search%20criteria%20and%20module%20name%20'Get-UnifiedGroup'.%20Try%20Get-PSRepository%20to%20see%20all%20available%20registered%20module%20repositories.%0AAt%20C%3A%5CProgram%20Files%5CWindowsPowerShell%5CModules%5CPowerShellGet%5C1.0.0.1%5CPSModule.psm1%3A1397%20char%3A3%0A%2B%20%20%20%20%20%20%20%20%20PackageManagement%5CFind-Package%20%40PSBoundParameters%20%7C%20Microsoft%20...%0A%2B%20%20%20%20%20%20%20%20%20~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~%0A%20%20%20%20%2B%20CategoryInfo%20%20%20%20%20%20%20%20%20%20%3A%20ObjectNotFound%3A%20(Microsoft.Power...ets.FindPackage%3AFindPackage)%20%5BFind-Package%5D%2C%20Exception%0A%20%20%20%20%2B%20FullyQualifiedErrorId%20%3A%20NoMatchFoundForCriteria%2CMicrosoft.PowerShell.PackageManagement.Cmdlets.FindPackage%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CDIV%20class%3D%22mceNonEditable%20lia-copypaste-placeholder%22%3E%26nbsp%3B%3C%2FDIV%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1166991%22%20slang%3D%22en-US%22%3ERe%3A%20Get%20SharePoint%20Site%20URL%20of%20an%20individual%20Microsoft%20Team%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1166991%22%20slang%3D%22en-US%22%3E%3CP%3EWell%20you%20cannot%20just%20expect%20every%20cmdlet%20to%20return%20the%26nbsp%3B%3CFONT%20style%3D%22background-color%3A%20%23ffffff%3B%22%3ESharePointSiteUrl%3C%2FFONT%3E%20value%2C%20Get-Team%20most%20certainly%20does%20not%20do%20it.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ETo%20use%20the%20Get-UnifiedGroup%20cmdlet%2C%20you%20need%20to%20connect%20to%20Exchange%20Online%20PowerShell%3A%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fpowershell%2Fexchange%2Fexchange-online%2Fconnect-to-exchange-online-powershell%2Fconnect-to-exchange-online-powershell%3Fview%3Dexchange-ps%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ehttps%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fpowershell%2Fexchange%2Fexchange-online%2Fconnect-to-exchange-online-powershell%2Fconnect-to-exchange-online-powershell%3Fview%3Dexchange-ps%3C%2FA%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1167146%22%20slang%3D%22en-US%22%3ERe%3A%20Get%20SharePoint%20Site%20URL%20of%20an%20individual%20Microsoft%20Team%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1167146%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F58%22%20target%3D%22_blank%22%3E%40Vasil%20Michev%3C%2FA%3E%26nbsp%3Bdo%20you%20have%20any%20suggestion%20on%20how%20to%20connect%20the%20dots%20from%20Get-Team%20to%20calling%20a%20SharePoint%20cmdlet%20and%20returning%20SharePointSiteURL%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAnd%20how%20odd%2C%20Get-UnifiedGroup%20was%20working%20for%20me%20last%20week%20without%20connecting%20to%20EXO...however%2C%20that%20is%20not%20really%20here%20nor%20there%20because%20I%20don't%20think%20I%20will%20be%20using%20it%20in%20my%20final%20script.%3C%2FP%3E%3C%2FLINGO-BODY%3E
Occasional Contributor

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, DisplayName)
ForEach ($T in $Teams) {
   $SPOURl = (Get-UnifiedGroup -Identity $T.GroupId | Select -ExpandProperty SharePointSiteURL)
   Write-Host "URL for the" $T.DisplayName "team is" $SPOURL }

 
It would be easiest to start with getting the Team by displayname then taking the group ID and using that. All the individual versions of -expandproperty SharePointURL have not worked for me yet. Any advice?

Get-Team -DisplayName $Team | Select GroupId

 

5 Replies

Might help if you give us the exact samples you are running, I don't see any problem with the above.

@Vasil Michev I am trying to do something like the two examples below

Get-Team -DisplayName $Team | Select GroupId
$SPOURL = (Get-Team -Identity $Team.GroupId | Select -ExpandProperty SharePointSiteURL)

 

Get-Team -DisplayName $Team | Select GroupId
$SPOURL = (Get-PnpSite -Identity $Team.GroupId | Select -ExpandProperty SharePointSiteURL)

@Mitch Crump I don't want to use UnifiedGroup because I only want a singular URL but now Get-UnifiedGroup is not working for me and I can't find the required module to install for it.

 

PS C:\WINDOWS\system32> Find-Module -Includes Cmdlet Get-UnifiedGroup
PackageManagement\Find-Package : No match was found for the specified search criteria and module name 'Get-UnifiedGroup'. Try Get-PSRepository to see all available registered module repositories.
At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\1.0.0.1\PSModule.psm1:1397 char:3
+         PackageManagement\Find-Package @PSBoundParameters | Microsoft ...
+         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (Microsoft.Power...ets.FindPackage:FindPackage) [Find-Package], Exception
    + FullyQualifiedErrorId : NoMatchFoundForCriteria,Microsoft.PowerShell.PackageManagement.Cmdlets.FindPackage

 

 

Well you cannot just expect every cmdlet to return the SharePointSiteUrl value, Get-Team most certainly does not do it.

 

To use the Get-UnifiedGroup cmdlet, you need to connect to Exchange Online PowerShell: https://docs.microsoft.com/en-us/powershell/exchange/exchange-online/connect-to-exchange-online-powe...

@Vasil Michev do you have any suggestion on how to connect the dots from Get-Team to calling a SharePoint cmdlet and returning SharePointSiteURL?

 

And how odd, Get-UnifiedGroup was working for me last week without connecting to EXO...however, that is not really here nor there because I don't think I will be using it in my final script.