PowerShell Azure AD V2.0 Add a list of users to a group

Here is a simple but powerful little nugget for adding Azure Active Directory user to an Azure Active Directory group.

Here is a simple but powerful little nugget for adding Azure Active Directory user to an Azure Active Directory group. 

 

User case: Microsoft has recently released functionality to grant O365 licenses to Azure AD groups which will automatically license the group’s members.  We automatically license our Intune users by licensing our Azure AD group: Mobility Users that contains our Intune users.

 

Just supply the <Group Object ID> 

Example: 898dbc5f-c02d-432f-9e7e-f19914ed8415

 

PowerShell:

 

$csv=Get-Content c:\temp\userlist.csv

foreach ($line1 in $csv)

{

$Users1=Get-AzureADUser -ObjectId $line1

$Users1 | ForEach {Add-AzureADGroupMember -ObjectId <Group Object ID> -RefObjectId $Users1.ObjectID}

}

Comments (0)


Leave a comment