Provisioning “Modern” Team Sites
There are four methods of provisioning “modern” team sites. These are: user interface, programmatically, PnP CSOM core component, and PnP PowerShell.
1. User Interface
One can provision from a user interface and can be done from:
a. SharePoint – provision direct from SharePoint Online; or
b. Office 365 Group – provision from an Office 365 Group from another location such as Outlook, which would then trigger the provisioning
The “modern” team sites in your tenant will have to be enabled by the administrator so that you can create “modern” team sites from the SharePoint home page. Additionally, you can create an Office 365 Group from Office 365 Outlook. By choosing the “site” tab of that group, you will be brought to the “modern” team site landing page. The SharePoint site creation process can be controlled from the SharePoint Online admin settings by choosing “modern” experience or “classic” experience.
The “modern” team sites can be programmatically created through Microsoft Graph. When creating an Office 365 group in Microsoft Graph, a “modern” team site is automatically provisioned for the group. The default structure for the “modern” team site URI is based on the mailNickname parameter of the Office 365 group: https://[tenant].sharepoint.com/sites/[mailNickname]
3. PnP CSOM Core Component
The PnP CSOM Core Component is available as a NuGet Package and has simplified methods for handling “modern” groups.
4. PnP PowerShell
Creating “modern” sites with PnP PowerShell provides the opportunity to authenticate with Microsoft Graph using Azure Active Directory. The following is a script that will create a “modern” team site and will return the actual SharePoint site URL for further manipulation. Through the URL of the created site, one can use either CSOM (with SharePoint PnP Core Component) or SharePoint PnP PowerShell to automate additional operations on the site. The script is as follows:
# Connect to Azure AD and get back an OAuth 2.0 Access Token
# This command will prompt the sign-in UI to authenticate
Connect-PnPMicrosoftGraph -Scopes "Group.ReadWrite.All","User.Read.All"
# Store the Access Token in a local variable
# This is not really needed for next steps, but is available $accessToken = Get-PnPAccessToken
# Create a new Office 365 Unified Group, together with the corresponding Modern Site in SPO
$group = New-PnPUnifiedGroup -DisplayName "Awesome Group" -Description "Awesome Group" -MailNickname "awesome-group" -Members "[email protected]", "[email protected]" -IsPrivate -GroupLogoPath .\logo.jpg
# Connect to the modern site using PnP PowerShell SP cmdlets
# Since we are connecting now to SP side, credentials will be asked
# Now we have access on the SharePoint site for any operations
$context = Get-PnPContext
$web = Get-PnPWeb
$web.WebTemplate + "#" + $web.Configuration
1. Unlisted Sites in SharePoint Admin UI/Tenant API: As “modern” team sites are not visible in the SharePoint Admin UI; the list can be accessed from the Office 365 Groups admin user interface (located under Office 365 admin portal). Only “classic” SharePoint sites are listed on the SharePoint Online admin user interface. This limitation also applies to the tenant API. In other words, “modern” team sites cannot be listed by using this API but can be via programmatically by using the Groups endpoint from Microsoft Graph.
2. Sub-Sites and “Classic” Templates: Sub-sites provisioned under the root site of a “modern” site collection will use “classic” templates as there currently are no sub-site templates available for the “modern” sub-sites. There is the capability of transforming a “classic” sub-site to a “modern” sub-site. This can be achieved by creating a “modern” page on the site. Finally, updating the welcome page to the newly created page will result in a “modern” experience.
With “modern” team sites, managing, accessing and communicating is simplified, streamlined and productive. As SharePoint continues to work towards the “modern” experience, we can expect more templates and flexibility towards transferring to the “modern” experience.
Provisioning “modern” team sites programmatically, (2017, March 27). Retrieved from https://msdn.microsoft.com/en-us/pnp_articles/modern-experience-customizations-provisioning-sites