How to remove managers of Microsoft Entra ID users using Remove-MgUserManagerByRef

Removing a Microsoft Entra ID user's manager

Managing Microsoft Entra ID user-manager relationships is crucial for maintaining accurate organizational hierarchies and enforcing access policies. IT administrators often need to remove a user's manager due to role changes, restructuring, or compliance requirements. While the Remove-MgUserManagerByRef PowerShell command in Microsoft Graph allows admins to detach a manager from a user profile, it requires scripting expertise and manual execution.

ManageEngine ADManager Plus is an identity governance and administration solution designed to simplify Microsoft Entra ID management and reporting. With advanced management actions and in-depth reports, it optimizes administrative tasks and minimizes IT workload.

Remove a Microsoft Entra ID user's manager using Microsoft Graph PowerShell

Prerequisites

Before running the Remove-MgUserManagerByRef cmdlet, ensure the following requirements are met:

  • The Microsoft Graph PowerShell module is installed. If it’s not installed, use the following command:
    Install-Module Microsoft.Graph -Scope CurrentUser
  • Connect to Microsoft Graph PowerShell with the necessary permissions to manage users:
    Connect-MgGraph -Scopes "User.ReadWrite.All"

Using the Remove-MgUserManagerByRef cmdlet to remove a Microsoft Entra ID user's manager

Use the Remove-MgUserManagerByRef cmdlet in Microsoft Graph PowerShell to remove managers of Microsoft Entra ID users. The syntax is as follows:

Remove-MgUserManagerByRef
-UserId <String>
[-IfMatch <String>]
[-ResponseHeadersVariable <String>]
[-Headers <IDictionary>]
[-PassThru]
[-ProgressAction <ActionPreference>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]

Example use case and script using the Remove-MgUserManagerByRef cmdlet

Example: Remove the manager of a user

Use this Graph PowerShell command to remove a Microsoft Entra ID user's manager.

Remove-MgUserManagerByRef -UserId '8a7c50d3-fcbd-4727-a889-8ab232dfea01'

Supported parameters

The table below lists key parameters that can be used with the Remove-MgUserManagerByRef cmdlet to remove Microsoft Entra ID users' managers.

Parameters Description
-Confirm This is to confirm before running the cmdlet.
-UserId This is the unique identifier of a user.
-WhatIf This shows what would happen if the cmdlet was run.

Challenges of using Graph PowerShell scripts to remove managers of Microsoft Entra ID users

  • Removing managers from Microsoft Entra ID users requires precise Graph PowerShell commands, making it difficult for admins unfamiliar with scripting.
  • The process requires elevated permissions, and misconfigured access rights can lead to authorization errors or security risks.
  • The Microsoft Graph API enforces throttling limits, which can slow down bulk operations and impact efficiency when modifying multiple users.
  • Identifying and troubleshooting issues such as missing manager attributes, permission errors, or API failures can be time-consuming and require advanced technical expertise.

Why use ADManager Plus for management and reporting?

  • Manage Microsoft Entra ID, Active Directory, and Microsoft 365 users and groups effortlessly from a single console.
  • Generate detailed, prebuilt reports on users, groups, permissions, and security settings to ensure compliance and visibility.
  • Perform bulk modifications, provisioning, and deprovisioning of users and groups without writing complex scripts.
  • Automate routine tasks like user onboarding, group modifications, and access management while enforcing approval-driven workflows.
  • Assign specific administrative tasks to help desk teams with granular access controls, reducing IT workload while maintaining security.

Streamline Microsoft Entra ID user provisioning and updates with ADManager Plus’ intuitive interface

 
  • Removing a Microsoft Entra ID user's manager
  • Remove a Microsoft Entra ID user's manager using Microsoft Graph PowerShell
  • Challenges of using Graph PowerShell scripts to remove managers of Microsoft Entra ID users
  • Why use ADManager Plus for management and reporting?
The one-stop solution to Active Directory Management and Reporting
Email Download Link