Skip to content

Bulk import users to AzureAD security groups and Exchange Online mail-enabled security group

Notifications You must be signed in to change notification settings

Benjamin-Italiaander/Bulk-Import-users-Azure

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 

Repository files navigation

Bulk Import users into AzureAD or ExchangeOnline Security groups and Mail-enabled-Security-groups

This is a small tutorial how to bulk add users to AzureAD security groups and Exchange Online Mail-enabled-Security-groups.

First export a security group or create a list of names You can create a file with the content showed below and save this file as c:\Users\myuser\users.csv

Open elevated-powershell (powershell as administrator) i prefer to use ISE-powershell First install/import the ExchangeOnlineManagement module

Import-Module ExchangeOnlineManagement 

check installed version, this must be at least Version 2

Get-Module ExchangeOnlineManagement 

Connect ot Office365 Exchane Online

Connect-ExchangeOnline -UserPrincipalName [email protected] 

There will be a pop-up to login with user credentials.

Now check if the import the users.csv file works, you will see the list of the users in this file. Import-Csv C:\Users\myuser\users.csv

If the check shows all users you can load the file into memory variable $Users

$Users = Import-Csv  C:\Users\italiaander\users.csv 

Import all users to the SecurityGroup (replace YourSecurityGroupName with a existing securitygroup) and copy past this

foreach ($User in $Users) {
    # Retrieve UPN
    $UPN = $User.UserPrincipalName
    Add-DistributionGroupMember -Identity "YourSecurityGroupName" -Member $UPN
    }

check if import worked with this command

Get-DistributionGroupMember -Identity "YourSecurityGroupName" 

About

Bulk import users to AzureAD security groups and Exchange Online mail-enabled security group

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published