web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Process PowerShell Out...
Power Automate
Answered

Process PowerShell Output as String in Power Automate

(0) ShareShare
ReportReport
Posted on 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.)

I have the same question (0)
  • Ukiman1014 Profile Picture
    on at

    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

     

  • Verified answer
    Agnius Bartninkas Profile Picture
    Most Valuable Professional on at

    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 at

    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.

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

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Valantis Profile Picture

Valantis 481

#2
11manish Profile Picture

11manish 278

#3
David_MA Profile Picture

David_MA 276 Super User 2026 Season 1

Last 30 days Overall leaderboard