This guide explains how to use the Get-MgDomain cmdlet in Microsoft Graph PowerShell to retrieve information about domains in your Microsoft 365 tenant. Learn how to fetch domain properties, verify domain status, and troubleshoot domain-related issues with practical examples
The Get-MgDomain cmdlet is a powerful tool in the Microsoft Graph PowerShell module designed to retrieve information about the domains in your Microsoft 365 environment. This article will cover the cmdlet syntax, usage examples, tips, possible errors and solutions, and a conclusion to provide a complete understanding of its functionality.
Install-Module Microsoft.Graph -Scope CurrentUser
Get-MgDomain [-DomainId <String>] [-Property <String[]>] [<CommonParameters>]
Get-MgDomain
This command retrieves all domains in the Microsoft 365 environment.
Get-MgDomain -DomainId "example.com"
This command retrieves information about the specified domain. Useful when dealing with multiple domains.
Get-MgDomain -Property Id,IsVerified,IsDefault
This command retrieves only the Id, IsVerified, and IsDefault properties of all domains.
Get-MgDomain -All | Where-Object { $_.isVerified -eq $true } | Select-Object Id, IsVerified, AuthenticationType
This command fetches all domains and filters out only the verified ones, displaying their ID, verification status, and authentication type. This is useful when ensuring only trusted domains are being used.
Error Message | Cause | Solution |
Invalid Domain ID | Get-MgDomain : Resource 'example.com' does not exist or one of its queried reference-property objects are not present. | Verify that the domain name is correct and exists in your Microsoft 365 environment. |
Insufficient Permissions | Get-MgDomain : Insufficient privileges to complete the operation. | Ensure that you have the necessary permissions to execute this cmdlet. Typically, you need to be a Global Administrator or have sufficient directory read permissions. |
Invalid Filter Syntax | Get-MgDomain : Invalid filter clause. | Verify the OData filter syntax and ensure it complies with the supported query options. Refer to the OData query documentation for more details. |
1. What is Get-MgDomain used for?
Get-MgDomain is a Microsoft Graph PowerShell cmdlet used to retrieve details about the domains configured in your Microsoft 365 tenant. It provides information such as verification status, authentication type, and supported services.
2. How can I retrieve all domains in my tenant?
Use the following command to list all domains:
Get-MgDomain -All
3. Can I check if a domain is verified?
Yes, you can check the verification status of a domain by retrieving the isVerified property:
Get-MgDomain | Select-Object Id, IsVerified
4. How can I fetch detailed properties for a specific domain?
Use the domain’s ID to fetch its detailed properties. Example:
Get-MgDomain -DomainId "<DomainName>"
5. Can I use Get-MgDomain to retrieve custom domain verification TXT records?
No. Get-MgDomain only provides basic domain information like ID, verification status, authentication type, etc. To retrieve DNS records for domain verification, use Get-MgDomainVerificationDnsRecord.
6. How can I list only the default domain using Graph PowerShell?
You can run the following command. It returns the domain marked as default in your Microsoft 365 tenant.
Get-MgDomain -All | Where-Object { $_.isDefault -eq $true }
AuthenticationType
to Determine Domain TypeGet-MgDomain
cmdlet includes an AuthenticationType
property that indicates whether a domain is Managed (cloud-only) or Federated (using AD FS or another identity provider).IsVerified
property is True
and its Status
is Active
.The Get-MgDomain cmdlet is a versatile and essential tool for managing and retrieving information about domains in a Microsoft 365 environment. By understanding its syntax, usage examples, tips, and how to handle possible errors, you can efficiently manage domain-related tasks. Leveraging this cmdlet allows for better insights and management of your organization's domain configurations.
© m365corner.com. All Rights Reserved. Design by HTML Codex