
Microsoft Group migration Challenge in Tenant-to-Tenant
Recently I was doing a Tenant-to-Tenant migration where source Microsoft 365 Tenant have over 300 Microsoft 365 Group associated sites and customer need all those groups to be migrated along with members and sites. SharePoint sites data can be migrated using migration tool but none of the migration tools allows to create Microsoft 365 groups.
Google Groups migration Challenge to Microsoft 365
Similar scenario we faced in another migration from Google Suite to Microsoft 365 where we have to migrate all the Google groups and their members which are not possible using any migration tool.
Solution
We can create the Microsoft 365 groups using Microsoft 365 Admin center and add users to it but that would be very manual process and not handy when you need to create multiple groups. I am sharing a PowerShell script which will be helpful for you create Microsoft 365 groups and add group owners and members directly.
You can place all the group name details in a scv file wit below parameters which we would need while creating the groups:
- GroupName (name of the group)
- GroupAlias (alias of the group, will be use as group email alias and associated SharePoint site url)
- Owners (Comma separated emails)
- Members (Comma separated emails)
- Privacy (pass Private or public parameters)
I have used Pnp and Graph PowerShell modules for the script. Use below script to create Microsoft 365 Groups in a single go:
Connect-PnPOnline -Url "https://MsTalk-admin.sharepoint.com/" -UseWebLogin
Connect-PnPOnline –Graph
$path = "D:\\createGroups.csv"
function StartGroupCreation()
{
$AllGroups = Import-Csv -Path $path
foreach ($group in $AllGroups) {
$Groupname = ''
$Owners = ''
$Members = ''
$Groupalias = ''
$Description = ''
$Groupprivacy = ''
$Groupname = $group.Name
$Owners = $group.Owners
$Members = $group.Members
$Groupalias = $group.Email
$Groupprivacy = $group.Privacy
CreateMicrosoft365Group -Groupname $Groupname -Groupalias $Groupalias -Owners $Owners -Members $Members -Groupprivacy $Groupprivacy
}
}
function CreateMicrosoft365Group($Groupname, $Groupalias, $Owners, $Members, $Groupprivacy)
{
$Groupalias = $Groupalias
$arrOwners = $Owners.split(',')
$arrMembers = $Members.split(',')
$NewGroup = ''
Write-Host 'Started creation ofM365 Group: ' + $Groupname
if ($Groupprivacy -eq 'Private')
{
$NewGroup = New-PnPMicrosoft365Group -DisplayName $Groupname -MailNickname $Groupalias -Description $Groupname -Owners $arrOwners -Members $arrMembers -IsPrivate
}
else
{
$NewGroup = New-PnPMicrosoft365Group -DisplayName $Groupname -MailNickname $Groupalias -Description $Groupname -Owners $arrOwners -Members $arrMembers
}
Write-Host Write-Host 'Created creation ofM365 Group: ' + $Groupname -ForegroundColor Green
}
From above script, call StartGroupCreation() function after compilation and this will start creation of script based on details added in CSV file.
No Comments