cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
MelissaReed
Advocate II
Advocate II

Is there a PAD equivalent for P/Au Cloud's Get User Profile action?

In running a Desktop flow, I need to store the current user's email address.

 

If I were in a Cloud flow I'd get WorkflowInitiator from the TriggerOutputs().

Is there an equivalent to that in PAD?    (using OOB functionality, not getting into C# coding, CMD line scripting, etc.)

 

The closest I can come is to pull the Windows Environment variable for Username. 

I could call a cloud flow that accepts that as a parameter and does a Get User Profile to return the email address.  But that seems awfully klunky.  Surely there's a way to get that info within PAD and I'm just not seeing it.

 

Am I missing something here or did Microsoft?

1 ACCEPTED SOLUTION

Accepted Solutions
VJR
Super User
Super User

Hi @MelissaReed 

 

Not sure if you need this. When the below command is run in the command prompt it gives the email address of the current logged-in user.

whoami /upn

 Run the same command via PAD to read the output.

View solution in original post

16 REPLIES 16
MichaelAnnis
Super User
Super User

Does this count?  It's PowerShell, but "Run PowerShell script" is a built-in action, and the PowerShell is very readable, not dangerous, just "Get Current Name":

 

Copy this and paste it into a subflow:

 

System.RunPowershellScript Script: $'''[System.Security.Principal.WindowsIdentity]::GetCurrent().Name''' ScriptOutput=> PowershellOutput ScriptError=> ScriptError
Text.SplitWithDelimiter Text: PowershellOutput CustomDelimiter: $'''\\''' IsRegEx: False Result=> TextList
Text.Trim Text: TextList[1] TrimOption: Text.TrimOption.ToEnd TrimmedText=> Username
SET Email TO $'''%Username%@centralbancorp.com'''

 

It looks like this:

MichaelAnnis_2-1639156627213.png

And you just replace your domain on line 4.

 

Let me know if this doesn't work for you.

 

VJR
Super User
Super User

Hi @MelissaReed 

 

I haven't used it but maybe its worth trying the "Get User Info" action of the Active Directory.

 

VJR_0-1639200063858.png

 

VJR
Super User
Super User

This link from Microsoft Learn will give you help on how to use this action.

Active Directory handling in Power Automate for desktop - Learn | Microsoft Docs

I was looking at this too. It I didn’t see how to get the current user info.

Tx for the suggestion -- it only returns my "distinguished name" which looks something like xyx42355. 

@VJR  Thanks for the link.   This doesn't cover how to retrieve properties for the current user.

Were you able to try the PowerShell Script, or is it not allowed?

@MichaelAnnis Thanks for such a thorough response!    Apologize for the delay, took a while to get a chance to test this.

1) I learned something:   I can actually paste in the text -- you meant LITERALLY paste it in!   And it generates the Disney boxes.   Cool!

2) Are there other functions besides GetUser() or .Name?   I was able to get your script to work but it only returned Domain/DistinguishedName    (ex: XXX\fjf45623)   I googled it to see if I could get more documentation on GetUser struck out.   Any ideas?

 

What I'm ultimately trying to do is get the current user's email so I can pass it to another process.

 

The split text and trim text in the previous post gets the username out of domain/username.  The split text separates them, and then the trim text removes a ghost space at the end of username, not sure why it shows up. 

@MichaelAnnis Maybe it's a quirk of my particular environment, but Username is not "John Smith" or John.Smith that I could tack an "@domain.com" onto.  It's something like fjf24332.    In Power Automate Cloud, I can use that value as a parameter for the cloud action  Office/Get user profile (V2) and pluck off the "Mail" property from the return value.   

 

My workaround is to pass that User code (not a name, the fjf42343 value) into the Cloud flow do the lookup there.

But what if this were a standalone PAD flow, where I would need to record the current user's email address.  I can't believe there's not a built-in for that.   

Here you go; copy and paste this into a subflow; forget everything else we did:

 

System.RunPowershellScript Script: $'''$searcher = [adsisearcher]\"(samaccountname=$env:USERNAME)\"
$searcher.FindOne().Properties.mail''' ScriptOutput=> PowershellOutput2 ScriptError2=> ScriptError

 

It should be one line like this:

MichaelAnnis_0-1639696912350.png

 

And inside will look like this:

MichaelAnnis_1-1639696960859.png

 

 

It will put the email out to the variable %PowershellOutput2%

 

Good luck!

VJR
Super User
Super User

Hi @MelissaReed 

 

Not sure if you need this. When the below command is run in the command prompt it gives the email address of the current logged-in user.

whoami /upn

 Run the same command via PAD to read the output.

@MichaelAnnis  Thanks for the followup response.  I am so appreciative of the time you spent providing the information and I am bookmarking it off for future reference.   I was able to use @VJR 's 

whoami /upn

 solution and putting that in a PAD "Run DOS Command" gave me the email address I needed in a simpler call.  (Wish I could tag BOTH solutions as accepted.)  But thanks again!

PERFECT!!!!  I just tried it and it ran perfectly (and quickly)   The windows call w/n Cloud can sometimes take a while to come back so I was thrilled to have a way to have that outside the Cloud flow.  Thanks!

1, you can.  2, you said no CMD, so that's why I was looking up the python scripts...no worries.

VJR
Super User
Super User

Hi @MelissaReed 

 

Glad to know the solution worked out for you.

 

Not many know, but the posts do have the capability to be marked for more than one solutions.

You could still go ahead and do that now.

 

Good day!

~VJ

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

May UG Leader Call Carousel 768x460.png

June User Group Leader Call

Join us on June 28 for our monthly User Group leader call!

MPA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

Power Automate Designer Feedback_carousel.jpg

Help make Flow Design easier

Are you new to designing flows? What is your biggest struggle with Power Automate Designer? Help us make it more user friendly!

Top Solution Authors
Top Kudoed Authors
Users online (2,988)