Functions/HealthCheck/Workflows/Get-AMHCDisconnectedWorkflowLink.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
function Get-AMHCDisconnectedWorkflowLink {
    <#
        .SYNOPSIS
            Disconnected Workflow Links
 
        .DESCRIPTION
            Workflow links that have one or both ends disconnected
 
        .PARAMETER Workflows
            The workflows to perform health check against
    #>

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

    foreach ($workflow in $Workflows) {
        foreach ($link in $workflow.Links) {
            if (($null -eq $link.SourceID) -or ($null -eq $link.DestinationID)) {
                [AMConstructHealthCheckItem]::New($workflow, "Link type: $($link.LinkType)")
            } elseif (-not (($link.SourceID -in @($workflow.Triggers.ID) + @($workflow.Items.ID)) -and
                     ($link.DestinationID -in @($workflow.Triggers.ID) + @($workflow.Items.ID)))) {
                [AMConstructHealthCheckItem]::New($workflow, "Link type: $($link.LinkType)")
            }
        }
    }
}