Reputation: 533
When I type this command "Add-AzureAccount" on Azure PowerShell, it returns all the tenants associated with the account. How to know which tenant belongs to the Active Directory that I have created in the same subscription using PowerShell. Lets say that the default domain created in the AD is abc.onmicrosoft.com. Using this msolDomainName, can i get the tenantid it is associated with?
Kindly suggest.
Upvotes: 1
Views: 2143
Reputation: 533
well, this was helpful:
param([string]$TenantName = (Read-Host "What is your tenant name? (abc.onmicrosoft.com)"))
[xml]$data = (New-Object System.Net.WebClient).DownloadString("https://login.windows.net/$TenantName/FederationMetadata/2007-06/FederationMetadata.xml")
$dirtyID = $data.EntityDescriptor.entityID.Replace("https://sts.windows.net/", "")
$dirtyID.Replace("/", "")
Upvotes: 2
Reputation: 257
Hope this command will help you
PS C:\>(Get-AzureAccount).ActiveDirectories.ActiveDirectoryTenantID
for detailed please use given link
Upvotes: 1