Skip to main content

Notifications

Community site session details

Community site session details

Session Id : kxWd5O2FfXryB9GXvnc+7w
Power Automate - Power Automate Desktop
Answered

Process PowerShell Output as String in Power Automate

Like (0) ShareShare
ReportReport
Posted on 7 Aug 2023 18:41:46 by

I have a Power Automate Flow which calls a Desktop flow that includes a step to execute a PowerShell script.  Since I'm still developing the script, it sometimes errors.  I have a Power Automate action that parses the PowershellOutput variable, emailing me if it failed or not and if it failed, the error text.  The first problem is that there are no line breaks in the script output in the email.  The second problem is I need to do some string manipulation, such as splitting off unneeded text - that's getting an error that it's expecting a string when it's getting an object.

 

How to do get the output from PowerShell back to Power Automate as a string (not an object) and how do I put in line breaks for insertion into the body of an email?  Maybe I need to do all the string manipulation and addition of line breaks in Power Automate Desktop?

Ukiman1014_0-1691433155059.png

Ukiman1014_1-1691433613764.png

(Please ignore that there is no variable in the condition - it dropped out while I was editing before the screenshot was taken.)

  • Ukiman1014 Profile Picture
    on 08 Aug 2023 at 18:28:06
    Re: Process PowerShell Output as String in Power Automate

    After getting Replace to work correctly, I ended up passing two variables out of PAD back to Power Automate.  One  with the original text and another with HTML for the email body.

  • Verified answer
    Agnius Bartninkas Profile Picture
    10,045 Most Valuable Professional on 08 Aug 2023 at 04:50:14
    Re: Process PowerShell Output as String in Power Automate

    String manipulation in PAD is quite a bit more powerful mainly because we can use regular expressions. I would actually even send the email via PAD, too, using the Office 365 Outlook actions.

     

    The problem with your Replace text action is that you are trying to use regular expressions, but have not enabled the "Use regular expressions for find and replace" toggle:

    Agnius_0-1691470194077.png

     

    Please enable this and it will then work.

    -------------------------------------------------------------------------
    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.

  • Ukiman1014 Profile Picture
    on 07 Aug 2023 at 19:15:51
    Re: Process PowerShell Output as String in Power Automate

    FYI, I have tried to replace the newline character in the Powershell output with "<br>" using Replace text, but it's unable to find the newline character.  (I've also tried just "\n" or "\r".)  

    Ukiman1014_0-1691435446452.png

     

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

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

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,651 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 65,999 Most Valuable Professional

Leaderboard
Loading started