Removing a domain from Microsoft Entra ID using Microsoft Graph PowerShell

What is the Remove-MgDomain cmdlet?

The Remove-MgDomain cmdlet in Microsoft Graph PowerShell allows IT administrators to remove a domain from a Microsoft Entra ID (formerly Azure AD) tenant. It helps maintain a clean tenant, prevents security risks, ensures compliance, resolves authentication issues, and avoids service conflicts in Microsoft 365.

Removing domains from Microsoft Entra ID tenant using Graph PowerShell

Prerequisites

Before using the Remove-MgDomain cmdlet, ensure the following:

  • The Microsoft Graph PowerShell module is installed. If not, install it using this script:
    Install-Module Microsoft.Graph -Scope CurrentUser
  • Connect to Microsoft Graph PowerShell with the required permissions.
  • Ensure that the domain is not associated with any active users, groups, or email addresses.

Using the Remove-MgDomain cmdlet

Run the following script to remove a domain:

Remove-MgDomain -DomainId "zky.com"

Examples

Example 1: Remove a domain from Microsoft Entra ID.

Remove-MgDomain -DomainId "zky.com"

Supported parameters

Parameters Description
-DomainId This parameter can be used to specify the domain you would like to remove.
-WhatIf This parameter allows you to simulate the command without executing it.
-Confirm This parameter asks for confirmation before executing the cmdlet.

Limitations of using Graph PowerShell scripts to manage Microsoft Entra ID

  • Graph PowerShell lacks an intuitive interface and requires scripting knowledge.
  • IT administrators often spend considerable time troubleshooting errors, taking focus from high priority tasks.
  • Task delegation is complex, requiring both technical proficiency and elevated permissions in Microsoft Entra ID.

Highlights of using ADManager Plus for Microsoft 365 management

ManageEngine ADManager Plus is an identity governance and administration tool with Microsoft 365 management and reporting capability that streamlines administrative tasks by eliminating the need for complex PowerShell scripting. With its intuitive, script-free interface and advanced capabilities, it enables effortless management of objects across Active Directory, Microsoft 365, and Google Workspace platforms.

  • Schedule and automate routine tasks such as user provisioning, password resets, and more.
  • Periodically review and manage Microsoft 365 users' access rights with automated access certification campaigns.
  • Gain in-depth visibility into risky objects in your Microsoft 365 environment and take proactive measures.
  • Delegate and oversee Microsoft 365 management tasks with multi-level workflows.

Manage your hybrid AD environment with ADManager Plus

 
  • What is the Remove-MgDomain cmdlet?
  • Removing a domain from Microsoft Entra ID tenant using Graph PowerShell
  • Limitations of using Graph PowerShell scripts to manage Microsoft Entra ID
  • Highlights of using ADManager Plus for Microsoft 365 management
The one-stop solution to Active Directory Management and Reporting
Email Download Link