Home » Office 365 » Remove-MsolScopedRoleMember

Remove-MsolScopedRoleMember

The Remove-MsolScopedRoleMember cmdlet in PowerShell removes a user from an administrative unit-scoped role in Microsoft Office 365.

The syntax to remove a member of the role who is granted that role over an administrative unit is given below.

Remove-MsolScopedRoleMember
      -RoleObjectId <Guid>
      -AdministrativeUnitObjectId <Guid>
      [-RoleMemberObjectId <Guid>]
      [-RoleMemberUserPrincipalName <String>]
      [-TenantId <Guid>]
      [<CommonParameters>]

In this article, we will discuss how to use the Remove-MsolScopedRoleMember cmdlet in PowerShell to remove a member from an administrator role that is scoped to the administrative unit in Azure Active Directory.

How to Remove a Member from an Administrative Unit-Scoped Role in Office 365

To remove a member from an administrative unit-scoped role in Office 365, use the Remove-MsolScopedRoleMember cmdlet in PowerShell with the -RoleObjectId and -AdministrativeObjectId parameters.

The -RoleObjectId parameter specifies the unique ID of the role from which to remove members. The -AdministrativeUnitObjectId parameter specifies the unique object ID of the administrative unit.

# Get the East Coast Administrative unit
$eastcoastAU = Get-MsolAdministrativeUnit -SearchString "East Coast"   

# Get the user belongs to User Administrator Role
$UserAdmin = Get-MsolRole -RoleName "User Administrator"  

# Get the user
$user = Get-MsolUser -UserPrincipalName "[email protected]" 

# Get members of the User Administrator role that is scoped to the administrative unit
Remove-MsolScopedRoleMember -RoleObjectId $UserAdmin.ObjectId -AdministrativeUnitObjectId $eastcoastAU.ObjectId -RoleMemberObjectId $user.ObjectId

This command removes the user “[email protected]” from the “User Administrator” role scoped for the administrative unit named “East Coast“.

Conclusion

I hope the above article on how to use the Remove-MsolScopedRoleMember cmdlet in PowerShell to remove a member from an administrator role scoped for the administrative unit is helpful to you.

You can find more topics about PowerShell Active Directory commands and PowerShell basics on the ShellGeek home page.

Related Links

Get-MsolRole

Get-MsolUser

Get-MsolAdministrativeUnit

Get-MsolScopedRoleMember