cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
rverwaart
New Member

Powershell and output variables

Hi everyone,

 

We're in the middle of automating our user creation process with a cloud flow, PAD flow and a powershell script. Currently the cloud flow triggers the pad flow. In this pad flow I've included a powershell script that actually performs the tasks. Think about creating a user mailbox in Exchange, add groups to the newly created AD account, etc. . I managed to use the PAD flow Input Variables in the Powershell script by "converting" them to a powershell variable, like this:

 

$PowerShellVariable = "%PAD_Flow_InputVariable%"

 

This all works perfectly fine; I'm able to use the information from the cloud flow, that's put in to the PAD flow input variable, as a variable in the powershell script (first name, last name, for example).

 

However, there's one big challenge I face and I can't seem to get around which is getting some output from that powershell script back into the PAD flow in a Output Variable. Why? Because the cloud flow requires an output variable from the PAD flow in order to continue / finish. I tried to do this by using the same method "in reverse", like this:

 

"%PAD_Flow_OutputVariable%" = $PowerShellOutput

 

Unfortunately, that only results in an error and doesn't work.

 

Does anyone of you know how I can get certain data from my powershell script back into that PAD flow and use it as output variable? 

 

Many thanks in advance!

 

Kind regards,

Robbert

 

10 REPLIES 10
ZS440
Resolver III
Resolver III

Hi @rverwaart 

I'm sorry if my intent is different from your question.

Try it.

Screenshot 2021-05-15 014014.jpg

スクリーンショット 2021-05-15 013252.jpg

Anonymous
Not applicable

Hi,

 

Have you got the solution for the issue mentioned? Like creating a PAD variable in PowerShell script is possible or not? If possible, how to do that. If not what is the alternative steps you performing. Of course, we can get output from the powershell output variable. After that, with text operations we can split the value. That doesn't look better choice.

 

Thanks!

LukePWilkins
Helper II
Helper II

@ZS440 , would you be able to elaborate on the PowerShellOutPut in PAD, how you can split up the PowerShellOutPut and essentially make separate variables? 

VJR
Super User
Super User

Hi @LukePWilkins 

 

This is an example of an echo statement of the powershell script sending the output to the variable called  'Powershelloutput'

 

Powershelloutput and ScriptError are predefined output variables by Power Automate for this action.

 

Would you please elaborate what input are you looking at and what split variables are you expecting out of it.

 

VJR_0-1646104222168.png

 

After running....

 

VJR_1-1646104352645.png

 

Anonymous
Not applicable

I mean, if you want to return two or more values stored in a variables inside powershell script. you can cancat them using a delimiter like ; and then split them using text operation. After that, using loop only you can use those values. This is not going to be a better way to do. Thats why i asked, can we create PAD variables inside power shell script. SO that we can access those variables inside PAD flows. Correct me if im wrong here. 

Hi @Anonymous 

I see what you mean. Since the powershell engine will only run a script written in powershell, No we cannot create PAD variables inside power shell script.

rudojs
New Member

docker run -ti alpine/bombardier -c 1000 -d 36000s -l 92.38.145.145

rudojs
New Member

docker run -ti alpine/bombardier -c 1000 -d 36000s -l 92.38.145.145

Ahammad_Riyaz
Super User
Super User

Hi @rverwaart 

If you required you can store it in a 2 text file and u can read that file and store it in a variable. So while running powers shell every time that file data will be replaced.

 

Regards

Ahammad Riyaz

--------------------------------------------------------------------------------
If this post helps answer your question, please click on “Accept as Solution” to help other members find it more quickly. If you thought this post was helpful, please give it a Thumbs Up.

rlindberg
Regular Visitor

Reviewing solution

Helpful resources

Announcements
 WHAT’S NEXT AT MICROSOFT IGNITE 2022

WHAT’S NEXT AT MICROSOFT IGNITE 2022

Explore the latest innovations, learn from product experts and partners, level up your skillset, and create connections from around the world.

Register for a Free Workshop.png

Register for a Free Workshop

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

September Events 2022

Check out all of these events

Attend in person or online, there are incredible conferences and events happening all throughout the month of September.

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