SharePoint Online - Unable to use the correct site template

asked 2020-08-24T12:47:31.437+00:00
Roland v.'t Kruys 1 Reputation point

I am running a Windows 10 Professional machine with the latest version of PowerShell and running the following modules: AzureAD 2.0.2.106, SharePointPnPPowerShellOnline 3.24.2008.1 and MicrosoftTeams 1.1.4

I am trying to write a PowerShell script to automate Team (Microsoft teams) creations. During the development, I've noticed that the template is constantly wrong. When I run the Get-SPOWebTemplate cmdlet, I am getting the following as available:

19863-image.png

But when running the following script, it displays a different template:

#Define Config Variables   
#Install-Module -Name SharePointPnPPowerShellOnline -Force  
#Import-Module -Name SharePointPnPPowerShellOnline  
  
$AdminCenterURL = "https://com-admin.sharepoint.com"  
$SiteURL = "https://com.sharepoint.com/sites/DKClients-3"  
$SiteTitle = "DK.Clients - 3"  
$SiteOwner = "admin_roland@contoso.com"  
$Template = "EHS#1"  
$Timezone = 3 #(GMT+01:00) Brussels, Copenhagen, Madrid, Paris     
  
Try   
{   
    #Connect to Tenant Admin      
    Connect-SPOService -URL https://com-admin.sharepoint.com  
  
    #Check if site exists already   
    $Site = Get-SPOSite -Limit ALL | Where {$_.Url -eq $SiteURL}  
    $DeletedSite = Get-SPODeletedSite -Limit ALL | Where {$_.Url -eq $SiteURL}   
  
    If ($Site -eq $null) {  
        If ($DeletedSite -ne $null) {   
        Remove-SPODeletedSite -Identity $SiteURL  
        write-host "Site $($SiteURL) was found in Recycle Bin and is now permanently deleted." -foregroundcolor Yellow  
        }  
  
        #sharepoint online pnp powershell to create communication site   
        New-SPOSite -Url $SiteURL -Owner $SiteOwner -StorageQuota 1024 -LocaleID 1033 -Template $Template -TimeZoneId $Timezone -Title $SiteTitle  
        write-host "Site Collection $($SiteURL) created successfully!" -foregroundcolor Green   
    }  
    else {   
        write-host "Site $($SiteURL) exists already! Create a new URL and rerun the script." -foregroundcolor Yellow   
    }   
}   
catch {   
    write-host "Error: $($_.Exception.Message)" -foregroundcolor Red   
}   

In the SharePoint Admin Center, it is display as: Team site (classic experience) instead of Team site. I have tried GROUP#0 and EHS#1 without success. When I manually create a new Team site, it uses the GROUP#0 template. But this is not possible using a PowerShell command.

QA:

  1. Is there a limitation or bug in New-SPOSite?
  2. Or am I overlooking something?
SharePoint
SharePoint
A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
5,977 questions
{count} votes

1 answer

Sort by: Most helpful
  1. answered 2020-08-24T15:23:37.327+00:00
    Trevor Seward 11,491 Reputation points Microsoft MVP

    If you're trying to automate Microsoft Teams creation, use the Teams PowerShell module:

    https://learn.microsoft.com/en-us/powershell/module/teams/new-team?view=teams-ps