Scenario

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, a distinguished professional, boasts an impressive track record as a Microsoft MVP, having achieved this prestigious recognition for the eighth consecutive year since 2015. With an extensive career spanning over 18 years, Adnan has honed his expertise in various domains, notably excelling in SharePoint, Microsoft 365, Microsoft Teams, the .Net Platform, and Microsoft BI. Presently, he holds the esteemed position of Senior Microsoft Consultant at Olive + Goose. Notably, Adnan served as the MCT Regional Lead for the Pakistan Chapter from 2012 to 2017, showcasing his leadership and commitment to fostering growth within the tech community. His journey in the realm of SharePoint spans 14 years, during which he has undertaken diverse projects involving both intranet and internet solutions for both private and government sectors. His impact has transcended geographical boundaries, leaving a mark on projects in the United States and the Gulf region, often collaborating with Fortune 500 companies. Beyond his roles, Adnan is a dedicated educator, sharing his insights and knowledge as a trainer. He also passionately advocates for technology, frequently engaging with the community through speaking engagements in various forums. His multifaceted contributions exemplify his dedication to the tech field and his role in driving its evolution.

Leave a Reply