john ddd
john ddd

Reputation: 7

Azure Powershell - How to get a subscription owner email?

I'm trying to run (Get-AzContext).Account.id in a powershell runbook (through the azure portal), to get the email of the currently connected user.

The issue is that the value returned seems to be hidden for some reason. Here's an example of the kind of output I'm receiving "d3f47515-0254-43tv-8060-c824e201088h"

Upvotes: 0

Views: 530

Answers (1)

Joy Wang
Joy Wang

Reputation: 42133

No, it is not been hidden. I suppose you Connect-AzAccount with the service principal in the runbook, not the user account. The d3f47515-0254-43tv-8060-c824e201088h is the Application ID of the service principal.

To confirm this, just run (Get-AzContext).Account.Type, it will return ServicePrincipal.

enter image description here

If you logged in with a user account, it will return the Userprincipal name(i.e. email you want, note, strictly speaking it is different from email, but from your description, it should be the one you want)

enter image description here

Upvotes: 3

Related Questions