Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Automate - Building Flows
Answered

Remove certain text from body output.

(1) ShareShare
ReportReport
Posted on by

I have an Azure automation job which connects to a remote PowerShell session, the connection details are always printed to the output body by default. I am also using the write-output cmd in my runbook to print errors to the output so I can include them in the job completion report.

 

I am looking for a way to filter out the connection details from the body so I only have the error output to include in my report.

 

The connection detail text is always going to be the same text, the error message will be different depending on the failure.

 

Below is an example of the output received from the Get job output action:

I want all of the text starting from "Account" and ending at "..." to removed. The LocationID text is the error output which I want to keep and include in my error report.

 

Account Environment Tenant TenantId ------- ----------- ------ -------- xxxxxxxx-ac41-44e0-b230-xxxxxxxx AzureCloud xxxxxxx-c694-4271-xxxx-4271-beee-9edb734...

 

LocationId xxx-xx-4497-8c90-7xxxxa9 not found. provide valid LocationId. You can check if Location exists using Get-CsOnlineLisLocation -LocationId <LocationId>

 

  • CU05081125-0 Profile Picture
    on at
    Re: Remove certain text from body output.

    Thank you, this does work, however I found that if add a compose action I am able to specify the body of the Get job output action as the input for the compose.

    I then used the parse JSON action and was able to get the "exceptions" attribute from the "get job output" body which contains just the error message I am looking to include.

  • Michael E. Gernaey Profile Picture
    43,266 Super User 2025 Season 1 on at
    Re: Remove certain text from body output.

    Hi @dewaltk 

     

    As @Paulie78  mentioned you can do slice, or you can use split and split the string by ...

    Then you get an array with the top part and lower parts and the ... is just gone.

     

    If you need the top part or anything like this in the future, split gets you both.


    If I have helped you, I would really appreciate if you please Mark my answer as Resolved/Answered, and give it a thumbs up, so it can help others

    Cheers

    Thank You
    Michael Gernaey MCT | MCSE | MCP | Self-Contractor| Ex-Microsoft
    https://gernaeysoftware.com
    LinkedIn: https://www.linkedin.com/in/michaelgernaey

  • Verified answer
    Paulie78 Profile Picture
    8,416 Super User 2025 Season 1 on at
    Re: Remove certain text from body output.

    You can do it using the slice expression. It is easier just to take everything from the word LocationId onwards, like this:

    2024-07-10_14-31-31.png

    The expression I used was: 

    slice(outputs('Compose'), indexOf(outputs('Compose'), 'LocationId'))

    and the output it produces is:

    LocationId xxx-xx-4497-8c90-7xxxxa9 not found. provide valid LocationId. You can check if Location exists using Get-CsOnlineLisLocation -LocationId <LocationId>

    Hope this helps.

     

    Blog: tachytelic.net

    YouTube: https://www.youtube.com/c/PaulieM/videos

    If I answered your question, please accept it as a solution 😘

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

Michael Gernaey – Community Spotlight

We are honored to recognize Michael Gernaey as our June 2025 Community…

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 566 Super User 2025 Season 1

#2
David_MA Profile Picture

David_MA 516 Super User 2025 Season 1

#3
stampcoin Profile Picture

stampcoin 492