I have a job that runs and reports on Agent job failures, it works fine but I want to parse the message to get the “Execution ID” if there is one and add that in the select as a separate field.
The regex to get the numbers after “Execution ID:” is what I’m looking for help with. I’ve tried adding various regex expressions in here “Expression={$_.Message}” but not found a solution.
The package execution failed. NOTE: The step was retried the requested number of times (1) without succeeding. The step failed.
Executed as user: domain\svcsql. Microsoft (R) SQL Server Execute Package Utility Version 11.0.7001.0 for 64-bit Copyright (C) Microsoft Corporation. All rights reserved. Started: 11:28:23 PM Package execution on IS Server failed.
Execution ID: 22522, Execution Status:4. To view the details for the execution, right-click on the Integration Services Catalog, and open the [All Executions] report Started: 11:28:23 PM Finished: 11:41:41 PM Elapsed: 797.562 seconds.
The package execution failed. NOTE: The step was retried the requested number of times (1) without succeeding. The step failed.
$Test= "The package execution failed. NOTE: The step was retried the requested number of times (1) without succeeding. The step failed.
Executed as user: domain\svcsql. Microsoft (R) SQL Server Execute Package Utility Version 11.0.7001.0 for 64-bit Copyright (C) Microsoft Corporation. All rights reserved. Started: 11:28:23 PM Package execution on IS Server failed.
Execution ID: 22522, Execution Status:4. To view the details for the execution, right-click on the Integration Services Catalog, and open the [All Executions] report Started: 11:28:23 PM Finished: 11:41:41 PM Elapsed: 797.562 seconds.
The package execution failed. NOTE: The step was retried the requested number of times (1) without succeeding. The step failed.
"
$Test -match "(?Execution ID: )(?\d*)"
$Matches.ExecIDText
$Matches.ExecIDValue
$Test= "The package execution failed. NOTE: The step was retried the requested number of times (1) without succeeding. The step failed.
Executed as user: domain\svcsql. Microsoft (R) SQL Server Execute Package Utility Version 11.0.7001.0 for 64-bit Copyright (C) Microsoft Corporation. All rights reserved. Started: 11:28:23 PM Package execution on IS Server failed.
Execution ID: 22522, Execution Status:4. To view the details for the execution, right-click on the Integration Services Catalog, and open the [All Executions] report Started: 11:28:23 PM Finished: 11:41:41 PM Elapsed: 797.562 seconds.
The package execution failed. NOTE: The step was retried the requested number of times (1) without succeeding. The step failed.
"
$Test -match "(?*ExecIDText*Execution ID: )(?*ExecIDValue*\d*)"
$Matches.ExecIDText
$Matches.ExecIDValue
$Test -match '(?Execution)'
Gives this result:
True
Execution ID:
22522
You’ll have to replace the * characters around the group names by “smaller than”, “greater that” signs, I’dont know how to get those characters in the code example (they’re interpreted as HTML ans erased)