Functions/HealthCheck/Workflows/Get-AMHCUnbuiltWorkflowItem.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-AMHCUnbuiltWorkflowItem {
    <#
        .SYNOPSIS
            Unbuilt Workflows Items
 
        .DESCRIPTION
            Workflows with unbuilt items
 
        .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,

        [Parameter(Mandatory = $true)]
        [AllowNull()]
        $Repository
    )

    foreach ($workflow in $Workflows) {
        foreach ($trigger in $workflow.Triggers) {
            if ($trigger.ConstructID -notin $Repository.ID) {
                [AMConstructHealthCheckItem]::New($workflow, "Type: $($trigger.ConstructType)")
            }
        }
        foreach ($item in $workflow.Items) {
            if ($item.ConstructID -notin $Repository.ID -and $item.ConstructType -notin "Evaluation","Wait") {
                [AMConstructHealthCheckItem]::New($workflow, "Type: $($item.ConstructType)")
            }
        }
    }
}