如何获取 Azure 租户 ID
Azure 租户 ID 是 Microsoft 365 租户的全局唯一标识符 (GUID)。它也称为 Office 365 租户 ID。该 ID 用于识别您的租户,而不是您的组织名称或域名。
获取 Azure 租户 ID 的方法有多种。您可以在 Azure 门户之一或使用 PowerShell 找到它。我已经为您列出了每个选项,因此您可以选择最适合您的选项。
获取 Azure 租户 ID
所需时间:2 分钟
获取 Azure 租户 ID 的最简单方法是从 Azure 管理中心。
在 Azure Active Directory 中查找 ID
您还可以在 Azure Active Directory (AAD) 中找到该 ID。
- 登录 aad.portal.azure.com
- 选择左侧的Azure Active Directory
- 打开属性找到租户 ID
使用 PowerShell 查找租户 ID
我们可以使用不同的 Office 365 PowerShell 模块来获取 Azure 租户 ID,例如 Msol 或 Azure AD。但实际上你不需要任何模块来获取 id。以下单行 cmdlet 将返回您的 ID,无需登录或使用任何模块。
只需确保将 Contoso 替换为您的 Office 365 域名
# Replace CONTOSO with your domain name
(Invoke-WebRequest https://login.windows.net/CONTOSO.onmicrosoft.com/.well-known/openid-configuration | ConvertFrom-Json).token_endpoint.Split('/')[3]使用微软在线服务模块
我们还可以使用PowerShell中的Msol服务来获取租户Id。确保您已连接到 Msol。
# Connect to Msol
Connect-MsolService
# Get tenant id
(Get-MSOLCompanyInformation).objectid.guid
另一种选择是从 AccountSku 中提取租户 ID。您将在 AccountObjectId 中找到租户 ID
Get-MsolAccountSku | fl使用 AzureAD 获取 Office 365 租户 ID
PowerShell中的AzureAd模块用于与Azure Active Directory配合使用,因此我们当然可以使用它来获取租户ID。
# If you are NOT connected to AzureAd yet
Connect-AzureAd | Select TenantId
# If you already have a connection
Get-AzureADTenantDetail总结
如今,Azure 租户 ID 很容易找到。如果您有任何疑问或有其他有用的方法来获取它,请在下面发表评论。


