question

NMBabu-1149 avatar image
0 Votes"
NMBabu-1149 asked shashishailaj edited

Assign bulk owners to bulk Azure Active Directory groups" in a single go by using powershell

We have N number of groups and need to add bulk owners to the AAD groups by using PowerShell

azure-ad-group-management
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

@NMBabu-1149 , When you say bulk owner ? Are you looking to add multiple group owner to a group ??

0 Votes 0 ·

1 Answer

shashishailaj avatar image
0 Votes"
shashishailaj answered shashishailaj edited

@NMBabu-1149 ,
If I understand correctly you would like to create a script which adds multiple owners to multiple groups by running a single powershell script . This can be done in multiple ways however I would use the simplest one. You would need to create a csv file with all the details for the owners that you want to add.

  • Export the list of groups in your organization with Object Ids and Display names. The output should look like in the screenshot.

     Connect-AzureAD       
     Get-AzureADGroup | Select-Object ObjectID, DisplayName | Export-Csv c:\temp\group.csv   
    

    • 189198-image.png

  • Export a list of users in your organization which you would like to add as owners with their Object Ids and Display Names . The output should be as in the screenshot.


         Connect-AzureAD       
         Get-AzureADUser | Select-Object ObjectId, DisplayName | Export-Csv C:\temp\users.csv  
    

    • 189168-image.png

  • Create a new csv file with the list of groups and the list of users to be added as owners. This is a manual step and will take time.

  • If you require to set multiple owners of the same group , you need to add the same group in the line.

  • Also if you see the details , I have modified the column titles to gObjectId (group objectid) gDisplayName (group displayname) UserOId (user objectid) UserDisplayName (user name) as per the usage in the script .
    • 189219-image.png

        Connect-AzureAD
              $Groups = Import-Csv "C:\Temp\groupOwner.csv"| ForEach-Object { 
                   Add-AzureADGroupOwner -ObjectId $($_.gObjectId) -RefObjectId $($_.userOid)
                   Write-Host "$($_.UserDisplayName) was added as a owner of the group $($_.gDisplayName)"
                   Get-AzureADGroupOwner -ObjectId $($_.gObjectId)
                   }
      

The output is received as below for the above script .

189281-image.png

Hope the above fits your requirement . Should you have any further query , do let us know. There could surely be other ways to do the same thing . But this will work for bulk group to bulk owner assignment . In any case you would have build a csv file beforehand in order to do it onetime. If the information in the post is helpful , do accept the post as answer which will help other members of the community searching for similar queries . We will be happy to help for any other query .



  • Please don't forget to click on 130616-image.png whenever the information provided helps you. Original posters help the community find answers faster by identifying the correct answer. Here is how

  • Want a reminder to come back and check responses? Here is how to subscribe to a notification

  • If you are interested in joining the VM program and help shape the future of Q&A: Here is how you can be part of Q&A Volunteer Moderators




image.png (10.6 KiB)
image.png (14.3 KiB)
image.png (22.8 KiB)
image.png (39.5 KiB)
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.