Last active
June 5, 2020 14:08
-
-
Save MCMXCIII/1d9e91033a205d74614232a1994312eb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Moving large groups of users to a group | |
#Just edit where the CSV is going to be and make sure to include the header of the list of users as "emailAddress" | |
#The fields you have to change are "$csvPath" to the folder with the csv | |
#and the "displayname -eq "Name of group" " | |
Import-Module AzureAD | |
#Connects to your Office365 tenant | |
Connect-AzureAD | |
$csvPath = "C:\Users\Kaz\Desktop\college.csv" | |
# currently set for adding kearneypeople access. | |
#This Scrip cannot add people to groups that are on the on prem | |
#It must be an azure AD group | |
$GroupId = Get-AzureADGroup -Filter "displayName eq 'Name Of Group'" | |
$users = Import-Csv -Path $csvPath | |
foreach ($user in $users){ | |
$UserObj = Get-AzureADUser -Filter "mail eq `'$($User.emailAddress)`'" | |
Add-AzureADGroupMember -ObjectId $GroupId.ObjectId -RefObjectId $UserObj.ObjectId | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment