This guide explains how to use the Get-MgOrganization cmdlet in Microsoft Graph PowerShell to retrieve details about your Microsoft 365 tenant. Learn how to fetch organization properties like tenant ID, display name, and verified domains with practical examples.
The Get-MgOrganization cmdlet is a powerful tool in Microsoft Graph PowerShell that allows administrators to retrieve details about their organization (tenant). This guide will cover the cmdlet syntax, provide usage examples, offer tips, address possible errors and solutions, and discuss various use cases.
The basic syntax of the Get-MgOrganization cmdlet is as follows:
Get-MgOrganization
This cmdlet does not require any parameters and will return details about the organization associated with the signed-in user.
Retrieve Organization Details
To get the full details of your organization, simply run:
Get-MgOrganization
This command will return comprehensive information about the organization, including its ID, display name, and more.
Retrieve Specific Properties
To get specific properties such as the display name and verified domains, run:
Get-MgOrganization | Select-Object DisplayName, VerifiedDomains
Retrieve Marketing Notification Email Addresses
To get the marketing notification email addresses set for your organization, run:
Get-MgOrganization | Select-Object MarketingNotificationEmails
Get-MgOrganization -Property DisplayName,VerifiedDomains
Get-MgOrganization -ExpandProperty Branding
Error | Solution |
Permission Denied: You receive a "Permission Denied" error when running the cmdlet. | Ensure that you have the necessary permissions to access organizational details. You may need to be a global administrator or have other appropriate roles assigned. |
Module Not Found: You get an error stating that the Get-MgOrganization cmdlet is not recognized. | Make sure you have installed and imported the Microsoft Graph PowerShell module. Run the following commands to install and import the module:
|
Invalid Authentication: Authentication fails when attempting to run the cmdlet. | Ensure you are authenticated to Microsoft Graph. Use the Connect-MgGraph cmdlet to authenticate:
|
1. What is Get-MgOrganization used for?
Get-MgOrganization is a Microsoft Graph PowerShell cmdlet used to retrieve information about your Microsoft 365 tenant, such as its name, tenant ID, and verified domains.
2. How can I retrieve basic details about my tenant?
Use the following command to retrieve tenant details:
Get-MgOrganization
3. How can I list the verified domains in my tenant?
Use the following script to extract verified domains:
(Get-MgOrganization).VerifiedDomains
4. Can I filter specific properties of the tenant?
Yes, you can select specific properties using Select-Object. Example:
Get-MgOrganization | Select-Object DisplayName, TenantId, Country
6. Can I retrieve multiple tenants using Get-MgOrganization?
No. Get-MgOrganization only returns the organization object for the currently connected tenant. If you manage multiple tenants, you’ll need to connect to each tenant separately using Connect-MgGraph.
7. Why is Get-MgOrganization returning limited fields even with -ExpandProperty?
Some fields require additional Graph permissions (like Directory.Read.All or Organization.Read.All). Ensure your app or session has sufficient privileges. Also, make sure the field you are expanding actually exists and is populated in your tenant.
Get-MgOrganization
, it will always return exactly one result, even if you don't specify an -OrganizationId
.DisplayName
, DefaultUsageLocation
, and MarketingNotificationEmails
.
Get-MgOrganization
works without specifying an ID, you can also pass the known OrganizationId
explicitly using the -OrganizationId
parameter.Get-MgOrganization -OrganizationId "your-org-id-here"
You can retrieve the Organization ID by running:
(Get-MgOrganization).Id
The Get-MgOrganization cmdlet is an essential tool for Microsoft 365 administrators, providing critical information about the organization's configuration and settings. By understanding how to use this cmdlet effectively, administrators can streamline their management tasks, ensure compliance, and automate reporting processes.
For more tips and comprehensive guides on using Microsoft Graph PowerShell, stay tuned to M365Corner.com!
© m365corner.com. All Rights Reserved. Design by HTML Codex