Functions/HealthCheck/Conditions/Get-AMHCUnusedCondition.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
function Get-AMHCUnusedCondition {
    <#
        .SYNOPSIS
            Unused Conditions
         
        .DESCRIPTION
            Conditions that are not used in any workflows
 
        .PARAMETER Conditions
            The conditions to perform health check against
 
        .PARAMETER Workflows
            The workflows to perform health check against
    #>

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

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

    foreach ($condition in $Conditions) {
        if ($Workflows.Items.ConstructID -notcontains $condition.ID -and `
            $Workflows.Triggers.ConstructID -notcontains $condition.ID) {
            [AMConstructHealthCheckItem]::New($condition, "Unused")
        }
    }
}