Is there a way to get the primary domain name using Azure Cli az ad command
There is no direct command to get Primary domain using Azure CLI.
Alternatively, you can make use of either Microsoft Graph Explorer or PowerShell like below:
In my Azure Portal, my Primary domain looks like this:
Using Microsoft Graph Explorer, you can run query like below:
GET https://graph.microsoft.com/v1.0/domains?$select=id
Response:
You can run the above query in Azure CLI using
az rest
method like below:
az rest --method get --url 'https://graph.microsoft.com/v1.0/domains?$select=id'
Response:
Using PowerShell, you can run command like below:
Connect-AzureAD
Get-AzureADDomain
Response:
References: