且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

PowerShell - 使用 Microsoft 帐户连接到 Azure Active Directory

更新时间:2022-11-04 08:23:50

(2018-04-23 更新,阐明如何使用 AzureAD (v2) 模块执行此操作.)

(Updated 2018-04-23 to clarify how to do this with AzureAD (v2) module.)

AzureAD (v2) PowerShell 模块接受 ‑TenantId 参数"nofollow noreferrer">Connect‑AzureAD,可以是 Guid 租户 ID,也可以是 Azure AD 租户中任何经过验证的域名.这样做将允许您使用外部帐户登录(例如,您的个人 Microsoft 帐户,或者来自另一个 Azure AD 租户的工作或学校帐户,只要此帐户之前曾被邀请加入租户):

The AzureAD (v2) PowerShell module accepts the ‑TenantId parameter in Connect‑AzureAD, which can be either the Guid tenant ID, or any verified domain name in the Azure AD tenant. Doing so will allow you to sign in using an external account (e.g. you personal Microsoft account, or a work or school account from another Azure AD tenant, as long as this account was previously invited into the tenant):

Connect-AzureAD -TenantId "contoso.com"

MSOnline (v1) 模块没有等效参数,但它接受 ‑AdGraphAccessToken‑MsGraphAccessToken,它们是 Azure AD Graph API (https://graph.windows.net) 和 Microsoft Graph API (https://graph.microsoft.com).虽然您可以使用 ADAL(例如)为您的特定租户(允许您使用外部用户)获取这些访问令牌,但为此为您的 Azure AD 租户创建一个本地"帐户可能更简单.

The MSOnline (v1) module does not have an equivalent parameter, but it does accept ‑AdGraphAccessToken and ‑MsGraphAccessToken, which are access tokens to the Azure AD Graph API (https://graph.windows.net) and the Microsoft Graph API (https://graph.microsoft.com), respectively. Though you can use ADAL (for example) to obtain these access tokens for your specific tenant (which allows you to use external users), it's probably simpler to just create a "local" account to your Azure AD tenant for this.

目前不支持使用 Microsoft 帐户登录 AAD PowerShell.您的方法(创建一个本地"目录的新用户)是可行的方法.