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>
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.
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
You can do it using the slice expression. It is easier just to take everything from the word LocationId onwards, like this:
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
566
Super User 2025 Season 1
David_MA
516
Super User 2025 Season 1
stampcoin
492