我正在尝试调用需要当前登录用户的PrincipalId的ARM模板.
https://docs.microsoft.com/en-us/azure/templates/microsoft.keyvault/vaults
我已经使用powershell作为组织的AAD中的访客帐户登录.
当我检查结果上下文时,我得到:
Name : [sky.sigal@ministryof.me, 5f813400-5b93-43b0-af8f-5fd04714f1ef]
Account : me@here.com
SubscriptionName : SomeSubscriptionName
TenantId : e6d2d4cc-b762-486e-8894-4f5f540d5f31
Environment : AzureCloud
我想知道如何从上面得到AAD ObjectId,没有字符串解析“名称”?
请注意,ARM模板的文档不是很清楚,所以不确定me@here.com是否也能正常工作(我假设它正在谈论Guid).
谢谢.
最佳答案 您可以尝试
Get-AzureRmADUser
来获取ObjectId.
样品:
Get-AzureRmADUser -UserPrincipalName "xxxx@xxxx.com"
结果:
Id是ObjectId,你可以得到它.此外,您可以通过其他属性获取它,而不仅仅是-UserPrincipalName,只需参考命令的链接即可.
更新:
如果您使用Guest帐户,则可以尝试以下命令.
Get-AzureADUser | ?{$_.UserType -eq "Guest"} | ?{$_.UserPrincipalName -like "*partofyouraccount*"}
注意:在使用此命令之前,您需要install Azure AD powershell module.