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>