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?
(Please ignore that there is no variable in the condition - it dropped out while I was editing before the screenshot was taken.)
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.
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:
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.
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".)
WarrenBelz
146,651
Most Valuable Professional
RandyHayes
76,287
Super User 2024 Season 1
Pstork1
65,999
Most Valuable Professional