Reputation: 57
i'm writing on behalf of a friend, that due to coronavirus has been "elected" as one of the global administraotr office 365 for school plan A1. Unfortuantely he has been involved, once the users had been already created on the tenant. they have more than 600 users divided in teacher, student and external collaborator. Unfortunately the company who created the accounts, did not create any AD group to divide them , but they :
follow this rule when creating account : [email protected] where xxx is "d" if the user is a teacher xxx is "s" if the user is a student xxx is "ose" if the user is an external collaborator
The "title" (or role) field contains "Teacher", "Student", "Collaborator" based on the user
He created 3 different AD Group "Teacher", "Student", "Collaborator", but in the user management , he cannot find a way to filter the users based on xxx@schoolname criteria , or sort/filter based on title or role (that is an available display column). If it would be available he could safely select part of the users and massively assign a group.
he has to select one by one , and ufortunatey the users are sorteb by name, so it is a big mess.
is there a way to apply the filter or sorting based on art of the account name ot title ? is there a way with powershell to do it ?
thanks in advance
Fabrizio
Upvotes: 1
Views: 69
Reputation: 16438
Yes. You can use Powershell script to make it.
Let's take Teacher as an example.
$users = Get-AzureADUser -All $true | Where-Object{($_.UserPrincipalName -like '*[email protected]')}
foreach ($user in $users) {
Add-AzureADGroupMember -ObjectId "{the ObjectId of the Teacher Group}" -RefObjectId $user.ObjectId
}
It will find all the users "*[email protected]" and add them into the Teacher Group.
Here are the cmd documents Get-AzureADUser and Add-AzureADGroupMember for your reference.
Upvotes: 1