【问题标题】:Add user to Azure AD from another Azure AD via powershell通过 powershell 从另一个 Azure AD 将用户添加到 Azure AD
【发布时间】:2014-12-18 18:45:38
【问题描述】:

在 Azure portal 我可以点击 Add User 并选择 User in another Windows Azure AD directory 将用户从另一个目录添加到当前目录(如只要我在两个目录中都有足够的授权)。

我希望能够通过 powershell 执行此操作,但这似乎不可能,因为您只能连接到单个目录。

这是场景: admin@tenant1.onmicrosoft.com 是租户 1 和租户 2 中的全局管理员。在门户中,我可以在登录为 admin@tenant1.onmicrosoft.com 时查看和管理这两个目录。
但在 powershell 中,如果我这样做:

$cred = Get-Credential -UserName admin@tenant1.onmicrosoft.com
Connect-MsolService -Credential $cred

我只能查看和管理tenant1 目录。所以我尝试了这个:

$cred = Get-Credential -UserName admin@tenant1.onmicrosoft.com
Connect-MsolService -Credential $cred
$user = Get-MsolUser -UserPrincipalName user@myfederateddomain.com

$cred2 = Get-Credential -UserName admin@tenant2.onmicrosoft.com
Connect-MsolService -Credential $cred2
$user | New-MsolUser

但这失败了:

New-MsolUser : Unable to create this user because the user principal name provided is not on a verified domain.
At line:1 char:9
+ $user | New-MsolUser
+         ~~~~~~~~~~~~
    + CategoryInfo          : OperationStopped: (:) [New-MsolUser], MicrosoftOnlineException
    + FullyQualifiedErrorId : Microsoft.Online.Administration.Automation.PropertyDomainValidationException,Microsoft.Online.Administ 
   ration.Automation.NewUser

我猜这是不可能的,但也许有人可以指出我错过的东西?

【问题讨论】:

  • 截至今天,我已尝试通过 portal.azure.com 执行此操作 - 它在那里工作,但来自 PowerShell 的相同操作 - 不起作用...

标签: powershell azure office365 azure-active-directory


【解决方案1】:

很遗憾,正如您所猜想的那样,此功能目前无法通过 Azure AD PowerShell 使用。这是我们希望在未来添加的内容,但我还没有确切的时间表。

2018 年 4 月 14 日更新:抱歉 - 没有对此进行监控。现在有一种方法可以使用 Microsoft Graph 将来自另一个租户的用户邀请到当前租户。请参阅https://developer.microsoft.com/en-us/graph/docs/api-reference/v1.0/resources/invitation。看起来仍然没有任何 Azure AD PowerShell 用于此。

【讨论】:

  • 有谁知道这个是否有更新,这个场景现在可以完成吗?还是有其他方法可以做到?
  • 今天仍然不能通过 PS 工作,所以我想还没有更新。
  • 查看带有选项的更新答案(但仍然没有 PowerShell)
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2014-04-02
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-06-20
  • 1970-01-01
  • 2021-04-12
相关资源
最近更新 更多