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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Remove certain text fr...
Power Automate
Unanswered

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>

 

Categories:
I have the same question (0)
  • Verified answer
    Paulie78 Profile Picture
    8,422 Moderator on at

    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 😘

  • Michael E. Gernaey Profile Picture
    53,325 Super User 2025 Season 2 on at

    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

  • CU05081125-0 Profile Picture
    on at

    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.

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 538 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 405 Moderator

#3
abm abm Profile Picture

abm abm 252 Most Valuable Professional

Last 30 days Overall leaderboard