Helpers/Test-SCOMMonitoringTaskResultForError.ps1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16

function Test-SCOMMonitoringTaskResultForError
{
    param
    (
        [Parameter(Mandatory = $true, ValueFromPipeline = $true)]
        [Microsoft.EnterpriseManagement.Runtime.TaskResult]
        $Result
    )

    if ($Result.Status -ne 'Succeeded')
    {
        Write-Error "Task failed with error code $($Result.ErrorCode): $($Result.ErrorMessage)"
    }
}