Pete is a VP of Technology at ThreeWill. Pete’s primary role is driving the overall technology strategy and roadmap for ThreeWill. Pete also serves as ThreeWill’s Hiring Manager and is constantly looking for new talent to join the ThreeWill family.
Teamify a Classic SharePoint Team Site with Microsoft 365
If your journey to the cloud has only just begun, then Microsoft 365 features like SharePoint, Teams, Planner, Flow and many more will be available immediately. Best of all you get all the “modern” goodness and get everything from the start. But what if you were an early adopter of Microsoft 365 and have many SharePoint classic Team sites? Or you migrated from on-premises and have many classic sites? What are your options for old fashioned SharePoint team sites that would benefit from new modern experiences that all hinge on an Microsoft 365 group, like Teams for example? One very simple option is to Groupify and Teamify a Classic SharePoint Team Site with Microsoft 365.
Microsoft 365 CLI v2 to the Rescue
One very simple way to do this is to use the awesome power of the Microsoft 365 CLI! If you have not installed the Microsoft 365 CLI, go do it NOW! I am NOT kidding.
Go, I’ll wait!
The Microsoft 365 CLI is an incredible tool to have in your toolbox (see my previous post). And the v2 release has added a ton of awesome features! There are 260+ commands to create, update, and manage Azure Active Directory Groups, classifications, schemaextensions, users, SharePoint lists, libraries, templates, site scripts, term-store, apps, pages, and so much more!
For this post, let’s take a look at how to connect a classic SharePoint Site to an Microsoft 365 Group and attach that group and SharePoint Site to a Microsoft Team. All of the modern goodness in 2, that’s right 2 commands
Groupify the Classic Team Site
To start, the
groupify command simply creates a new group. The magic behind this command is a call to the
_api/GroupSiteManager/CreateGroupForSite endpoint to create a Group. For example, running the following…
o365 spo site groupify --siteUrl https://contoso.sharepoint.com/teams/classicsite --alias groupified-site --displayName Groupified --isPublic
… will quickly return the following result.
DocumentsUrl: null ErrorMessage: null GroupId : cca35647-a39e-4833-8c14-cf50e32e350e SiteStatus : 2 SiteUrl : https://contoso.sharepoint.com/teams/sustainment
Teamify the new Group
Once the group has been created, then we are ready to associate a Team with the group. Again, a simple call to the Microsoft 365 CLI, this time to the
o365 teams team add --groupId cca35647-a39e-4833-8c14-cf50e32e350e
The above simply calls the MS Graph API to add a Team to the group we just created. The call is a PUT to the
/groups/[group-id]/teamendpoint to add a Team to the Microsoft 365 group we just created.
PnP Sites Core and PowerShell Options
These capabilities also exist in the recent PnP updates for Core and PowerShell cmdlets. The SiteCollection.GroupifyAsync and the Add-PnPOffice365GroupToSite cmdlet enable the same behavior if you prefer either of those options. I’m partial to the CLI tools these days, but the SharePoint PnP Community has got you covered!
Some Final Thoughts
That’s it, we just teamified a group. The Microsoft 365 CLI is very powerful, helping accomplish some valuable tasks with minimal effort. This is a greate community effort!
But there were some items that gave me some trouble. When using these commands, here a few notes:
- If you re-run the
groupifycommand without checking for an existing group, it will create another group. Using
o365 spo site getto get the site properties and check the site
GroupIdproperty in advance addresses this issue. The problem arises when this property exists and is a valid guid. In this case the group already exists and the site is already “groupified”, but the command will simply create another group. Probably not what you want! But keep reading, I got you covered!
- If you create a Channel in Teams with an existing folder of the same name, the Channel will use the existing folder. This certainly simplifies things. You could also enhance the script that follows to provision those Channels if needed using
o365 teams channel add. I’ll leave that as an exercise for you dear reader! 🙂
- There is usually a timing gap between the creation of the group and availbility of the group to provision a Team. I have seen as little as 30 seconds, but rarely more than 2 mins. A simple wait period to ensure the
o365 teams team addcall completes does the trick.
And if you have ever had to seed some test data, say for SharePoint lists, views, or even just a standard application? If so, this is a simple, but very powerful use of Generics and LINQ to load some test data and even get related data seeded into SharePoint lists in this previous blog post I put out.
A Sample Script (a gist actually)
A full script that deals with the items above is available as a gist below. This is a simple script, but hopefully someone can get a little value out of it. There are some prerequisites, but the script checks for those and provides links to install the requirements.
Leave me a comment below if you have trouble or feedback.