Solved

Add users to an AAD group through Powershell

Posted on 2016-11-02
4
59 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 41

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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The Nano Server Image Builder helps you create a custom Nano Server image and bootable USB media with the aid of a graphical interface. Based on the inputs you provide, it generates images for deployment and creates reusable PowerShell scripts that …
Previously, on our Nano Server Deployment series, we've created a new nano server image and deployed it on a physical server in part 2. Now we will go through configuration.
In a previous video Micro Tutorial here at Experts Exchange (http://www.experts-exchange.com/videos/1358/How-to-get-a-free-trial-of-Office-365-with-the-Office-2016-desktop-applications.html), I explained how to get a free, one-month trial of Office …
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…

739 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