The Add-MsolRoleMember cmdlet in PowerShell adds a member to an administrator role in Microsoft Office 365. This command supports only users and service principals added to a role. Adding a security group is not supported.
The syntax to add a user to an administrator role in Office 365 is given below.
Add-MsolRoleMember -RoleObjectId <Guid> [-RoleMemberType <RoleMemberType>] [-RoleMemberObjectId <Guid>] [-RoleMemberEmailAddress <String>] -RoleName <String> [-TenantId <Guid>] [<CommonParameters>]
In this article, we will discuss how to use the Add-MsolRoleMember cmdlet in PowerShell to add a member to an administrator role in Office 365.
How to Add a Member to an Administrator Role in Office 365
To add a member to an administrator role in Office 365, use the Add-MsolRoleMember command with the
-RoleName parameter and
-RoleName parameter specifies the name of the role to which to add the members. The
-RoleMemberEmailAddress parameter specifies the member to add.
Add-MsolRoleMember -RoleName "User Administrator" -RoleMemberEmailAddress "[email protected]"
This command adds “[email protected]“, to the “User Administrator” role. You can use the
Get-MsolRole cmdlet to get the list of values for the –
To verify the user added successfully to the role, use the Get-MsolRole command to get the Role objectId and store it in
$Role. The Get-MsolRoleMember uses the
-RoleObjectId to specify the role object id and retrieves the member that belongs to the Role.
The PowerShell script is given below.
# get the role object id $Role = Get-MsolRole -RoleName "User Administrator" # Get the member that belongs to the Role Get-MsolRoleMember -RoleObjectId $Role.ObjectId RoleMemberType EmailAddress DisplayName isLicensed -------------- ------------ ----------- ---------- User [email protected] shell geek True
I hope the above article on how to use the Add-MsolRoleMember command in PowerShell to add a member to the Role is helpful to you.
You can find more topics about PowerShell Active Directory commands and PowerShell basics on the ShellGeek home page.