Solved

Add users to an AAD group through Powershell

Posted on 2016-11-02
4
30 Views
Last Modified: 2016-11-02
Need a quick answer so any help would be appreciated.

Does anyone have a powershell script to add ALL USERS and INDIVIDUAL USERS to AAD groups. We have a group in AZURE AD that I need to populate with several hundred users.

This is an Pure Cloud based solution of Office 365

Ta
0
Comment
Question by:John Davies
  • 2
4 Comments
 
LVL 17

Expert Comment

by:Gaurav Singh
ID: 41869787
0
 

Author Comment

by:John Davies
ID: 41869893
Hi Gaurav, this has no on prem, it is purely cloud am trying to add users to an AZURE AD group, cant use the Import-Module ActiveDirectory

Import-Module : The specified module 'activedirectory' was not loaded because no valid module file was found in any module directory.
0
 
LVL 38

Accepted Solution

by:
Vasil Michev (MVP) earned 500 total points
ID: 41869920
You can use the WAAD PowerShell module and the Add-MsolGroupMember cmdlet. For example, to add all users to a specific group:

$group = Get-MsolGroup | ? {$_.DisplayName -eq "test"} | select -ExpandProperty ObjectId

Get-MsolUser -All | % { Add-MsolGroupMember -GroupObjectId $group.Guid -GroupMemberObjectId $_.ObjectId.Guid }

Open in new window


Or, if you are using Exchange Online as well, take advantage of the Add-DistributionGroupMember cmdlet, which is far more convenient:

Get-User | % { Add-DistributionGroupMember DG -Member $_.UserPrincipalName -WhatIf }

Open in new window


Here are links to the modules:

https://technet.microsoft.com/en-us/library/dn975125.aspx
https://technet.microsoft.com/en-us/library/jj984289(v=exchg.160).aspx
0
 

Author Closing Comment

by:John Davies
ID: 41870587
Thank you, worked a treat.
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Exchange server is not supported in any cloud-hosted platform (other than Azure with Azure Premium Storage).
Follow this checklist to learn more about the 15 things you should never include in an email signature from personal quotes, animated gifs and out-of-date marketing content.
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now