Created
June 2, 2020 13:36
-
-
Save MCMXCIII/e104bd5e172f5ea01cc6cdd1b3a46c82 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 "email address" | |
Import-Module AzureAD | |
#Connects to your Office365 tenant | |
#This will prompt for credentials | |
Connect-AzureAD | |
#Link the csv file to read from.(Please use the exact path.) | |
$csvPath = "C:\" | |
# currently set for adding kearneyconnect access. | |
$GroupId = Get-AzureADGroup -Filter "displayName eq 'KearneyConnect_SSO_Standard_Users'" | |
#Using the CSV to find the user being moved. | |
$users = Import-Csv -Path $csvPath | |
#Loop through | |
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