Functions/HealthCheck/Workflows/Get-AMHCDisabledWorkflowItem.ps1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
function Get-AMHCDisabledWorkflowItem {
    <#
        .SYNOPSIS
            Disabled Workflow Items
 
        .DESCRIPTION
            Workflow items that are disabled
 
        .PARAMETER Workflows
            The workflows to perform health check against
 
        .PARAMETER Repository
            The workflows, tasks, conditions and processes to perform health check against
    #>

    [CmdletBinding()]
    param (
        [Parameter(Mandatory = $true)]
        [AllowNull()]
        $Workflows,

        $Repository
    )

    foreach ($workflow in $Workflows) {
        foreach ($trigger in $workflow.Triggers) {
            if (-not $trigger.Enabled) {
                $repoItem = $Repository | Where-Object {$_.ID -eq $trigger.ConstructID}
                [AMConstructHealthCheckItem]::New($workflow, "$($trigger.TriggerType): $($repoItem.Name)")
            }
        }
        foreach ($item in $workflow.Items) {
            if (-not $item.Enabled) {
                $repoItem = $Repository | Where-Object {$_.ID -eq $item.ConstructID}
                [AMConstructHealthCheckItem]::New($workflow, "$($item.ConstructType): $($repoItem.Name)")
            }
        }
    }
}