Thank you for posting this in Microsoft Q&A.
I understand you want to add multiple groups to a user.
Yes, there is a way to add multiple groups to a user account at once using PowerShell.
Below is the PowerShell script.
Creates a CSV file named GroupsList.csv
that includes a column for GroupNames
Install-Module AzureAD
Import-Module AzureAD
Connect-AzureAD
$userUPN = "reprouser@r.onmicrosoft.com"
$csvFilePath = "C:\customroles\GroupsList.csv"
$groupNames = Import-Csv -Path $csvFilePath | Select-Object -ExpandProperty GroupNames
foreach ($groupName in $groupNames) {
Add-AzureADGroupMember -ObjectId (Get-AzureADGroup -Filter "DisplayName eq '$groupName'").ObjectId -RefObjectId (Get-AzureADUser -ObjectId $userUPN).ObjectId
}
Hope this helps. Do let us know if you any further queries.
Thanks,
Navya.
If the answer is helpful, please click "Accept Answer" and kindly "upvote" it.