One of the best things about having a centralized authentication system is that all the information is easily accessible everywhere in the company. If you use SharePoint, you see this all the time, in lists, permissions, and more. So it’s no surprise that Power Automate provides us a way to fetch a person’s information, like country, display name, city, and picture, to name a few. To do this you have the Get User Profile action. It’s quite powerful so let’s explore it a bit further.

Where to find it?

To find it, you can search for the “Get User Profile” action.

Alert:
Microsoft changed the way that Power Automate displays the steps. Now you have a huge list of actions that you can search. It’s arguable that this is simpler or not, but now I’ll only provide the search string you have to write to find the action.

Here’s what it looks like.

Usage

The action refers to the user’s UPN or “User Principal Name,” which refers to the person’s name plus some information to make it unique. This is defined by your administrator, and it’s quite complex, so that I won’t describe it here. If you’re curious, you can go to the Azure AD reference page that explains this in further detail. What I want to show you is the other option. The email. It’s one of the safest ways to access the person’s information because:

  1. There are no special characters (names can be tricky in this regard)
  2. An email has a defined structure, so it’s easier to validate.
  3. It can be obtained in a lot of other actions while the UPN is trickier.

So my main recommendation is to use email when possible.

When you use the action, it won’t try to autocomplete your results. This is because you can have an expression to calculate the email or clean it up from another step in the Flow. Regardless you’ll get something like this:

As you can see, there’s quite a lot of information that you can get from the action. I’m only showing you a subset above.

Limitations

You can only get information from the users in your tenant (this is not necessary for your whole organization since it may be split into several areas). Also, you can only see the “public” information or the information that your administrator allows everyone to see. You can find the same information in the person’s profile in teams or outlook.

Recommendations

Here are some things to keep in mind.

Don’t calculate the UPN.

The UPN has a formula but doesn’t try to calculate it. If there’s an action that returns it, use it as is to get the best results. If you try to generate yourself, you’ll get some headaches and failing Flows.

Don’t generate the email.

Same as above. Emails may be generated using a formula, but things change, and there are exceptions. For example, how many David Smiths do you think a large organization has? Or Manuel Gomes in Portugal, for that matter 😀. My point is to use the email that comes from another action and avoid as possible hard-code it yourself.

Fetch only the fields you need

Aside from the UPN, there’s also an option to select the fields. You can define what fields you want to get, and the action will only fetch those. You’ll get a boost in performance if you do this, so keep this in mind. There are a lot of fields, so here’s the full list.

Name it correctly

The name is super important in this case since we’re getting the information of someone, but we need to define why we’re getting that information. Always build the name so that other people can understand what you are using without opening the action and checking the details.

Always add a comment.

Adding a comment will also help to avoid mistakes. Indicate why you are using that name, for example, where and how. Again, it’s important to enable faster debugging when something goes wrong.

Always deal with errors.

Have your Flow fail graciously when the user doesn’t exist and notify someone that something failed. It’s horrible to have failing Flows in Power Automate since they may go unlooked for a while or generate even worse errors. I have a template, and a template that you can use that will help you make your Flow resistant to issues. You can check all details here.

Am I missing something? Leave a comment or interact on Twitter. Let’s work together to make this reference as complete as we can

Back to the Power Automate Action Reference.

Photo by Ayo Ogunseinde on Unsplash

Manuel Gomes

I have 18 years of experience in automation, project management, and development. In addition to that, I have been writing for this website for over 3 years now, providing readers with valuable insights and information. I hope my expertise allows me to create compelling, informative content that resonates with the audience.

View all posts by Manuel Gomes →

5 thoughts on “Power Automate: Office 365 – Get User Profile Action

  1. Would be great if the Azure ‘Get Group Members’ connecter included the option to also pull AAD values such as city. Not sure why MS would not inlcude that as an option. Accessing graph api is not always an option for all orgs.

  2. Hello Manuel,

    I’m trying to obtain the Display Names from emails that we receive in an official company mailbox. However, not all emails come from within the company, some come from outside sources (other companies or personal emails such as @gmail, @yahoo, etc). In those cases, my workflow fails and gives me an “User not found” message.

    From what I understood the “Get User Profile (V2)” won’t work with these outside sources. Is there any other Action that would work to retrieve those Display Names? I need to get them all, from both inside and outside the company.

    1. Hi William,
      The “Get user Profile” will only get the internal users for your organization.
      The only way I can see this is to get the name from the email since the email usually comes like “Name” . If this is the case, you can use the expression:
      first(split(last(split(INSERT EMAIL FIELD HERE,’<')),'>‘))
      If the email is “Manuel Gomes” then you’ll get “Manuel Gomes”.
      I understand it’s a workaround, but it could work for your case.
      You can dot the following. Create a parallel path that will only run when the “Get User Profile” fails. If it doesn’t fail, then you have the name. If it doesn’t, try to get the email with the expression above.
      Can you please try and let me know if it works?

  3. Hello Manuel! I used the Get User Profile v2 and Get my profile for my reminder email flow, I used both because I’m including someone else to receive the notification, well I receive it, but the other user doesn’t, and I don’t know if this is related to user access permissions

Leave a Reply

Your email address will not be published. Required fields are marked *