标签: azure powershell azure-powershell azureportal
我正在尝试在Powershell Runbook中运行(Get-AzContext).Account.id(通过azure门户),以获取当前连接的用户的电子邮件。
(Get-AzContext).Account.id
问题在于,由于某种原因,返回的值似乎被隐藏了。 这是我收到“ d3f47515-0254-43tv-8060-c824e201088h”
d3f47515-0254-43tv-8060-c824e201088h
答案 0 :(得分:2)
否,它没有被隐藏。我想您Connect-AzAccount在运行簿中使用service principal,而不是user帐户。 d3f47515-0254-43tv-8060-c824e201088h是服务主体的Application ID。
Connect-AzAccount
service principal
user
Application ID
要确认这一点,只需运行(Get-AzContext).Account.Type,它将返回ServicePrincipal。
(Get-AzContext).Account.Type
ServicePrincipal
如果您使用用户帐户登录,它将返回Userprincipal name(即,您想要的电子邮件,请注意,严格来说,它与电子邮件不同,但是从您的描述来看,它应该是您想要的)
Userprincipal name