Functions/HealthCheck/AgentGroups/Get-AMHCUnusedAgentGroup.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-AMHCUnusedAgentGroup {
    <#
        .SYNOPSIS
            Unused Agent Groups
 
        .DESCRIPTION
            Agent groups that are not used in any workflows
 
        .PARAMETER AgentGroups
            The agent groups to perform health check against
 
        .PARAMETER Workflows
            The workflows to perform health check against
    #>

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

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

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