O365 Groups Migration – Automate Site Creation

I have recently been involved in a lot of migration ranging from on-premise SharePoint server farm to O365 and O365 tenant to tenant due to mergers & acquisitions and platform modernization. One such migration was from one tenant to another in O365. The scenario was to migrate O365 groups and sites associated with it.e problem that I am going to discuss here is the O365 group site creation on behalf of user. With the volume of data so large migration projects always need lots of automation to be done. When we create a O365 group from the UI it sends an email to the user mailbox and user needs to visit a link found in the email for the provisioning engine, running in the background, to create its Modern Team site in SharePoint Online. But when we create lots of groups using PowerShell we can’t expect users to visit the link sent in the mailbox for the site to be provisioned for them.To automate this part, we analyzed the URL that O365 sends in the mailbox which user needs to click for the site to be created. The URL was  https://tenantname.sharepoint.com/_layouts/groupstatus.aspx?id=567da1b0-8a75-4405-9553-12e8c30c1234&target=site.Or something similar. If we decode this, the URL can be split into something like this:  https://tenantURL/_layouts/groupstatus.aspx?id=O365GroupId&target=site 

With this in mind, the idea is simple:

  1.       When we create the group extract the created group’s GUID or generate the list of all groups create using  Get-UnifiedGroup | Format-List Id, DisplayName,EmailAddressesThe key is to include Id in the list of parameters, preferably in the very beginning. When we had Id in the end of the parameters list we found it to be not returning the GUID; not sure why will that happen..      
  2.        Export this list into a CSV
  3.        Run a tool which will read the CSV and does following:
      • Extracts the GUID for each group/row in the CSV
      • Prepares the URL in the similar way that is listed above or found in test users’ mailbox
      • Hits SharePoint online using CSOM and WebClient.

You can find the project at my Github repository here.

If you liked the article, share it with your friends and colleagues. You can also send a “Thank you” note by buying me a coffee. Buy Me a Coffee

Leave a Comment

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