Error with Get-RemoteDomain Cmdlet in PowerShell for Exchange Online

Slava G 0 Reputation points
2025-02-01T18:06:10.11+00:00

Encountering an error when trying to run the Get-RemoteDomain cmdlet: "The term 'Get-RemoteDomain' is not recognized as the name of a cmdlet."

All required modules are installed since the Get-Mailbox command runs successfully. The environment uses certificate-based authentication, and the service principal is in the Global Administrators group. The Azure Enterprise App has all necessary permissions (attached screenshot).

permissions

When making an HTTPS request (in postman) for Get-RemoteDomain, the response is: "cmdlet Get-RemoteDomain is not present in the role definition of the current user," suggesting a role definition issue. However, the way to fix this is unclear.

Running Get-Module shows the Exchange module commands, returning tmpEXO_rbow3fx5.agc. Then executing Get-Command -Module tmpEXO_rbow3fx5.agc | Select-String Get-RemoteDomain yields no results.

Advice on resolving this issue would be appreciated.

Microsoft Exchange Online
Microsoft Exchange Online Management
Microsoft Exchange Online Management
Microsoft Exchange Online: A Microsoft email and calendaring hosted service.Management: The act or process of organizing, handling, directing or controlling something.
4,734 questions
PowerShell
PowerShell
A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
2,795 questions
{count} votes

Accepted answer
  1. Xintao Qiao-MSFT 6,190 Reputation points Microsoft Vendor
    2025-02-07T05:40:08.3333333+00:00

    Hi, @Slava G

    Great to know that the issue has already been resolved and thanks for sharing the solution so that others experiencing the same thing can easily reference this! Since the Microsoft Q&A community has a policy that "The question author cannot accept their own answer. They can only accept answers by others", I'll repost your solution in case you'd like to "[Accept]" the answer : )     

    Issue Symptom: 

    Encountering an error when trying to run the Get-RemoteDomain cmdlet: "The term 'Get-RemoteDomain' is not recognized as the name of a cmdlet."

    When making an HTTPS request (in postman) for Get-RemoteDomain, the response is: "cmdlet Get-RemoteDomain is not present in the role definition of the current user." 

     

    Resolution: 

    A new service body with the same ID as the installed application object needs to be created before the missing role can be assigned.

    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Xintao Qiao-MSFT 6,190 Reputation points Microsoft Vendor
    2025-02-03T02:59:47.18+00:00

    Hi, @Slava G

    Based on your reported error message, a common cause of this problem is due to not installing the correct module or not assigning the necessary roles.

    Given that the Get-Mailbox command is able to run successfully, you first need to follow the steps in this document to check that you have the necessary permissions to run this command.

    Find the permissions required to run any Exchange cmdlet | Microsoft Learn

    User's image

    Once you have the necessary permissions, you can run the Get-RemoteDomain cmdlet to view configuration information for remote domains configured in your organization.


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.