Functions/HealthCheck/Tasks/Get-AMHCDuplicateTask.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
function Get-AMHCDuplicateTask {
    <#
        .SYNOPSIS
            Duplicate Tasks
 
        .DESCRIPTION
            Tasks that have the same AML as another task
 
        .PARAMETER Tasks
            The tasks to perform health check against
    #>

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

    $grouping = $Tasks | Where-Object {-not [string]::IsNullOrEmpty($_.AML)} | Group-Object AML
    foreach ($group in ($grouping | Where-Object {$_.Count -gt 1})) {
        foreach ($task in $group.Group) {
            [AMConstructHealthCheckItem]::New($task, "Duplicates: $($group.Group.Name -join " ,")")
        }
    }
}