Skip to main content

Notifications

Community site session details

Community site session details

Session Id : TT0/xOdxRTtc2cjFYLgNPv
Power Automate - Power Automate Desktop
Answered

Passing information out of PowerShell script via PowerShellOutput variable

Like (0) ShareShare
ReportReport
Posted on 2 Aug 2023 19:17:45 by

I am just beginning to use PowerShell in Power Automate Desktop.  I have a fairly complex script that needs to run (creating a Microsoft Team) and I will need to pass various results back after the script finishes.  Since I'm just starting, my script is only attempting to pass a variable straight through.

 

%TeamName% is an input variable that I set to "Test Team", then I call the PowerShell script, which is just this:


$TeamName = "%TeamName%"
write-output $TeamName

 

Ukiman1014_0-1691005470940.png

Ukiman1014_1-1691005509962.png

 

It looks like the issue is that I'm using the "Read text from file" action to read in the .ps1 script file into a variable, which is then executed by the script.

Ukiman1014_0-1691006601795.png

Is there a way to do this while still reading the script from a file?  It is so much more convenient than having to edit the script in the little window.  Right now, the script is just two lines, but the script I will need to run is much longer, so being able to use a script editor, just clicking "save", instead of clearing out the window and cutting and pasting the code is definitely desirable.

  • Verified answer
    Agnius Bartninkas Profile Picture
    10,045 Most Valuable Professional on 03 Aug 2023 at 04:52:38
    Re: Passing information out of PowerShell script via PowerShellOutput variable

    If you want to read the script from a file, your script will be stored as a literal text. You would then need to use Replace text to replace the placeholders in the script with actual variable values. I would suggest using some other notation in the script file and avoiding the percentage marks, as those will make it harder to replace it afterwards (you would need to escape the % by doing %% instead). 

    -------------------------------------------------------------------------
    If I have answered your question, please mark it as the preferred solution. If you like my response, please give it a Thumbs Up.

    I also provide paid consultancy and development services using Power Automate. If you're interested, DM me and we can discuss it.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Understanding Microsoft Agents - Introductory Session

Confused about how agents work across the Microsoft ecosystem? Register today!

Markus Franz – Community Spotlight

We are honored to recognize Markus Franz as our April 2025 Community…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,668 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 66,004 Most Valuable Professional

Leaderboard
Loading started
Loading complete