Archiv

Posts Tagged ‘M365’

Master the Lookup – Microsoft AAD/EntraID get all Tenant and Azure Subscription Details

Do you ever find yourself in a situation where you need to match an ID to its corresponding name in Microsoft Partner Center, Azure, or M365? Or perhaps you need to do the reverse? Here are some quick solutions:

1) Looking up TenantID from DNS-Name

2) Looking up DNS-Name from TenantID (for tenants you have no access)

3) Getting TenantID for SubscriptionID (for subscriptions you have no access)

function get-tenantIdFromSubscriptionID($subId){
    $response = try {
        (Invoke-WebRequest -UseBasicParsing -Uri "https://management.azure.com/subscriptions/$($subId)?api-version=2015-01-01" -ErrorAction Stop).BaseResponse
    } catch {
        $_.Exception.Response
    }
    $stringHeader = $response.Headers.ToString()
    return ($stringHeader.SubString($stringHeader.IndexOf("login.windows.net") + 18, 36))
}

These handy tools and methods will help you master the art of matching IDs with their corresponding names in the Microsoft Azure ecosystem.

Kategorien:Allgemein Schlagwörter: , , , , ,