Provision folder structure for Files tab in Teams

The Teams Files tab is always empty when we create a new channel. But this can be controlled to include a folder structure or other content that is surfaced in Teams.

When you create a group in Microsoft 365, you also get an associated SharePoint site and Teams team. Within your Teams team, you get a General channel, which, among others contains a Files tab..

folder structure teams

The Files tab is nothing but a view to a folder named after the channel in the Documents library of the associated site. So to create a default folder structure or content to display in Teams Files tab, all we need is to create those assets in the SharePoint site.

Provision folder structure

Luckily, we have many options to provision/create content in SharePoint. In this specific case, I will focus on the PnP Provisioning engine. This engine allows us to define and apply tenant templates, which can include customisations for both the SharePoint site and associated Teams team.
For this example, we will have a template that creates the following folder structure inside the General channel of a team:

  • 1 – Test folder
    • 1.1 – Test folder
    • 1.2 – Test folder
    • 1.3 – Test folder 1.3
  • 2 – Test folder
    • 2.1 – Test folder
    • 2.2 – Test folder
    • 2.3 – Test folder

This is defined as an XML template that can be applied via:

It’s really up to you how and when to apply the template. The template below was based on a client project where a custom application was used to create project sites.

Sample XML Template

Note that all folders are created inside a General folder, to match the channel name.

(Sample based on this article from Paolo Pialorsi to the Collab Magazine)

<pnp:Provisioning xmlns:pnp="http://schemas.dev.office.com/PnP/2020/02/ProvisioningSchema"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" Author="Storm" Generator="Manual" Version="1.0" Description="A sample Provisioning template to test Teams provisioning" DisplayName="Provisioning test">

    <pnp:Preferences Author="Storm" Version="1.0" Generator="Manual">
        <pnp:Parameters>
            <pnp:Parameter Key="Title"></pnp:Parameter>
            <pnp:Parameter Key="Alias"></pnp:Parameter>
            <pnp:Parameter Key="Description"></pnp:Parameter>
            <pnp:Parameter Key="OwnerUPN"></pnp:Parameter>
        </pnp:Parameters>
    </pnp:Preferences>

    <pnp:Templates ID="SAMPLE-TEMPLATES">

        <pnp:ProvisioningTemplate ID="ProjectsWorkspaceTemplate" Version="1.0" BaseSiteTemplate="GROUP#0" DisplayName="Projects Template" Description="Workspace template for projects" Scope="RootSite" TemplateCultureInfo="1040">

            <pnp:Lists>
                <pnp:ListInstance Title="Documents" Description="" DocumentTemplate="{site}/Shared Documents/Forms/template.dotx" OnQuickLaunch="true" TemplateType="101" Url="Shared Documents" EnableVersioning="true" MinorVersionLimit="0" MaxVersionLimit="500" DraftVersionVisibility="0" TemplateFeatureID="00bfea71-e717-4e80-aa17-d0c71b360101" EnableAttachments="false" ListExperience="NewExperience" DefaultDisplayFormUrl="{site}/Shared Documents/Forms/DispForm.aspx" DefaultEditFormUrl="{site}/Shared Documents/Forms/EditForm.aspx" DefaultNewFormUrl="{site}/Shared Documents/Forms/Upload.aspx" ImageUrl="/_layouts/15/images/itdl.png?rev=47" IrmExpire="false" IrmReject="false" IsApplicationList="false" ValidationFormula="" ValidationMessage="">
                    <pnp:ContentTypeBindings>
                        <pnp:ContentTypeBinding ContentTypeID="0x0101" Default="true" />
                        <pnp:ContentTypeBinding ContentTypeID="0x0120" />
                    </pnp:ContentTypeBindings>
                    <pnp:Views>
                        <View Name="{F71E4764-D0D2-46A8-9F78-FDEF3377F6B4}" DefaultView="TRUE" MobileView="TRUE" MobileDefaultView="TRUE" Type="HTML" DisplayName="All Documents" Url="{site}/Shared Documents/Forms/AllItems.aspx" Level="1" BaseViewID="1" ContentTypeID="0x" ImageUrl="/_layouts/15/images/dlicon.png?rev=47">
                            <Query>
                                <OrderBy>
                                    <FieldRef Name="FileLeafRef" />
                                </OrderBy>
                            </Query>
                            <ViewFields>
                                <FieldRef Name="DocIcon" />
                                <FieldRef Name="LinkFilename" />
                                <FieldRef Name="Modified" />
                                <FieldRef Name="Editor" />
                            </ViewFields>
                            <RowLimit Paged="TRUE">30</RowLimit>
                            <JSLink>clienttemplates.js</JSLink>
                        </View>
                    </pnp:Views>
                    <pnp:Folders>
                        <pnp:Folder Name="General">
                            <pnp:Folder Name="1 - Test folder">
                                <pnp:Folder Name="1.1 - Test folder" />
                                <pnp:Folder Name="1.2 - Test folder" />
                                <pnp:Folder Name="1.3 - Test folder" />
                            </pnp:Folder>
                            <pnp:Folder Name="2 - Test folder">
                                <pnp:Folder Name="2.1 - Test folder" />
                                <pnp:Folder Name="2.2 - Test folder" />
                                <pnp:Folder Name="2.3 - Test folder" />
                            </pnp:Folder>
                        </pnp:Folder>
                    </pnp:Folders>
                </pnp:ListInstance>
            </pnp:Lists>
        </pnp:ProvisioningTemplate>

    </pnp:Templates>

    <pnp:Sequence ID="SAMPLE-SEQUENCE">

        <pnp:SiteCollections>
            <pnp:SiteCollection xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="pnp:TeamSite" ProvisioningId="TEAMSITE01" Title="{parameter:Title}" Alias="{parameter:Alias}" DisplayName="{parameter:Title}" IsPublic="true" IsHubSite="false" Description="{parameter:Description}" Teamify="true" HideTeamify="true" Language="1033">
                <pnp:Templates>
                    <pnp:ProvisioningTemplateReference ID="ProjectsWorkspaceTemplate" />
                </pnp:Templates>
            </pnp:SiteCollection>
        </pnp:SiteCollections>

    </pnp:Sequence>

    <pnp:Teams>

        <pnp:Team GroupId="{sequencesitegroupid:TEAMSITE01}" DisplayName="{parameter:Title}" Description="{parameter:Description}" Visibility="Public" MailNickname="{parameter:Alias}">
            <pnp:Security>
                <pnp:Owners ClearExistingItems="false">
                    <pnp:User UserPrincipalName="{parameter:OwnerUPN}" />
                </pnp:Owners>
            </pnp:Security>
            <pnp:Channels>
                <pnp:Channel DisplayName="General" Description="General" IsFavoriteByDefault="true">
                    <pnp:Tabs>
                        <pnp:Tab DisplayName="Wiki" TeamsAppId="" Remove="true" />
                    </pnp:Tabs>
                </pnp:Channel>
            </pnp:Channels>
        </pnp:Team>

    </pnp:Teams>

</pnp:Provisioning>

PnP.PowerShell can be used to easily apply the template to a site as this can be done simply with two lines of code. Connect-PnPOnline offers many options to connect and you can use the option that best suits your needs

Connect-PnPOnline -Url "https://contoso.sharepoint.com" -Interactive
Invoke-PnPSiteTemplate -Path template.xml

4 Replies to “Provision folder structure for Files tab in Teams”

    1. Hi, sorry for the late reply, had an issue with comments…
      Thanks for the feedback, post updated

  1. Where did the GUID come from in the line:
    <View Name="{F71E4764-D0D2-46A8-9F78-FDEF3377F6B4}"…..

    1. Hi, the base for the template was exported using PnP PowerShell from a site I was using as reference for testing

Leave a Reply

Your email address will not be published. Required fields are marked *