Recently we did a google suite to Microsoft 365 migration, there were around 700 Google groups which we need to add as Microsoft 365 groups. We have created all groups using PowerShell script and added all the users using the same script. During testing we got the details that there were users who were not added to the security groups. So we have written a PowerShell script for adding missing users to the respective groups.

Adding Users M365 Groups using PowerShell

We created the csv file where we have all the Microsoft 365 Group alias names and added users in Owner and Member columns. In PowerShell cmdlet, we have exported the PowerShell and executed the below script function to add users to relevant roles in M365 groups.

function UpdateM365GroupPermissions($Groupalias, $Owners, $Members)
    $Groupalias = $Groupalias
    $arrOwners = $Owners.split(',')
    $arrMembers = $Members.split(',')
    write-host 'Owners:  ' $arrOwners
    write-host 'Members:  ' $arrMembers
    Write-Host 'Updateing Group permissions:  ' $Groupalias
    Add-PnPMicrosoft365GroupOwner -Identity $Groupalias -Users $arrOwners 
    Add-PnPMicrosoft365GroupMember -Identity $Groupalias -Users $arrMembers
    Write-Host 'Updated Group permissions' -ForegroundColor Green


Adnan is six time Microsoft MVP (Since 2015) with over 16 years of extensive experience with major expertise on SharePoint, SharePoint based development, Microsoft 365, Microsoft Teams, .Net Platform and Microsoft BI. He is currently working Sr Microsoft Consultant at Olive + Goose. He is MCT Regional Lead for Pakistan Chapter since 2012. He is working on SharePoint for past 12 years and worked on different intranet/intranet solutions for private & govt. sector majorly in United states and Gulf region and have experience of working with multiple Fortune 500 companies. He is a trainer, technology evangelist and also speaks in community forums.

Leave a Reply