Azure Powershell-如何获取订阅所有者的电子邮件?

时间:2020-01-06 00:29:29

标签: azure powershell azure-powershell azureportal

我正在尝试在Powershell Runbook中运行(Get-AzContext).Account.id(通过azure门户),以获取当前连接的用户的电子邮件。

问题在于,由于某种原因,返回的值似乎被隐藏了。 这是我收到“ d3f47515-0254-43tv-8060-c824e201088h

的输出类型的示例

1 个答案:

答案 0 :(得分:2)

否,它没有被隐藏。我想您Connect-AzAccount在运行簿中使用service principal,而不是user帐户。 d3f47515-0254-43tv-8060-c824e201088h是服务主体的Application ID

要确认这一点,只需运行(Get-AzContext).Account.Type,它将返回ServicePrincipal

enter image description here

如果您使用用户帐户登录,它将返回Userprincipal name(即,您想要的电子邮件,请注意,严格来说,它与电子邮件不同,但是从您的描述来看,它应该是您想要的)

enter image description here